|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.android.builder.core.AndroidBuilder
public class AndroidBuilder
This is the main builder class. It is given all the data to process the build (such as
DefaultProductFlavor
s, DefaultBuildType
and dependencies) and use them when doing specific
build steps.
To use:
create a builder with AndroidBuilder(String, String, ILogger, boolean)
then build steps can be done with
#mergeManifests(java.io.File, java.util.List, java.util.List, String, int, String, String, String, String, com.android.manifmerger.ManifestMerger2.MergeType, java.util.Map)
#processTestManifest2(String, String, String, String, String, Boolean, Boolean, java.util.List, java.io.File)
processResources(java.io.File, java.io.File, java.io.File, java.util.List, String, String, String, String, String, com.android.builder.core.VariantConfiguration.Type, boolean, com.android.builder.model.AaptOptions, java.util.Collection, boolean)
compileAllAidlFiles(java.util.List, java.io.File, java.io.File, java.util.List, com.android.builder.compiling.DependencyFileProcessor)
convertByteCode(Iterable, Iterable, java.io.File, DexOptions, java.util.List, boolean)
packageApk(String, java.io.File, java.util.Collection, String, java.util.Collection, java.util.Set, boolean, com.android.builder.model.SigningConfig, com.android.builder.model.PackagingOptions, String)
Java compilation is not handled but the builder provides the bootclasspath with
getBootClasspath()
.
Constructor Summary | |
---|---|
AndroidBuilder(java.lang.String projectId,
java.lang.String createdBy,
com.android.utils.ILogger logger,
boolean verboseExec)
Creates an AndroidBuilder. |
Method Summary | |
---|---|
void |
compileAidlFile(java.io.File sourceFolder,
java.io.File aidlFile,
java.io.File sourceOutputDir,
java.io.File parcelableOutputDir,
java.util.List<java.io.File> importFolders,
DependencyFileProcessor dependencyFileProcessor)
Compiles the given aidl file. |
void |
compileAllAidlFiles(java.util.List<java.io.File> sourceFolders,
java.io.File sourceOutputDir,
java.io.File parcelableOutputDir,
java.util.List<java.io.File> importFolders,
DependencyFileProcessor dependencyFileProcessor)
Compiles all the aidl files found in the given source folders. |
void |
compileAllRenderscriptFiles(java.util.List<java.io.File> sourceFolders,
java.util.List<java.io.File> importFolders,
java.io.File sourceOutputDir,
java.io.File resOutputDir,
java.io.File objOutputDir,
java.io.File libOutputDir,
int targetApi,
boolean debugBuild,
int optimLevel,
boolean ndkMode,
boolean supportMode,
java.util.Set<java.lang.String> abiFilters)
Compiles all the renderscript files found in the given source folders. |
void |
convertByteCode(java.lang.Iterable<java.io.File> inputs,
java.lang.Iterable<java.io.File> preDexedLibraries,
java.io.File outDexFolder,
DexOptions dexOptions,
java.util.List<java.lang.String> additionalParameters,
boolean incremental)
Converts the bytecode to Dalvik format |
static com.android.builder.model.ClassField |
createClassField(java.lang.String type,
java.lang.String name,
java.lang.String value)
|
void |
generateApkData(java.io.File apkFile,
java.io.File outResFolder,
java.lang.String mainPkgName,
java.lang.String resName)
|
void |
generateApkDataEntryInManifest(java.io.File manifestFile)
|
com.android.ide.common.internal.PngCruncher |
getAaptCruncher()
Returns an PngCruncher using aapt underneath |
java.util.List<java.lang.String> |
getBootClasspath()
Helper method to get the boot classpath to be used during compilation. |
com.android.ide.common.internal.CommandLineRunner |
getCommandLineRunner()
|
java.util.Set<java.io.File> |
getCompileClasspath(VariantConfiguration variantConfiguration)
Returns the compile classpath for this config. |
java.util.List<java.io.File> |
getLeafFolders(java.lang.String extension,
java.util.List<java.io.File>... importFolders)
Computes and returns the leaf folders based on a given file extension. |
java.util.Set<java.io.File> |
getPackagedJars(VariantConfiguration variantConfiguration)
Returns the list of packaged jars for this config. |
java.io.File |
getRenderScriptSupportJar()
Returns the jar file for the renderscript mode. |
SdkInfo |
getSdkInfo()
Returns the SdkInfo, if set. |
java.io.File |
getSupportNativeLibFolder()
Returns the native lib folder for the renderscript mode. |
com.android.sdklib.IAndroidTarget |
getTarget()
Returns the compilation target, if set. |
java.lang.String |
getTargetCodename()
|
TargetInfo |
getTargetInfo()
Returns the TargetInfo, if set. |
boolean |
isPreviewTarget()
Returns whether the compilation target is a preview. |
void |
mergeManifests(java.io.File mainManifest,
java.util.List<java.io.File> manifestOverlays,
java.util.List<? extends ManifestDependency> libraries,
java.lang.String packageOverride,
int versionCode,
java.lang.String versionName,
java.lang.String minSdkVersion,
java.lang.String targetSdkVersion,
java.lang.Integer maxSdkVersion,
java.lang.String outManifestLocation,
com.android.manifmerger.ManifestMerger2.MergeType mergeType,
java.util.Map<java.lang.String,java.lang.String> placeHolders)
Invoke the Manifest Merger version 2. |
void |
packageApk(java.lang.String androidResPkgLocation,
java.io.File dexFolder,
java.util.Collection<java.io.File> packagedJars,
java.lang.String javaResourcesLocation,
java.util.Collection<java.io.File> jniLibsFolders,
java.util.Set<java.lang.String> abiFilters,
boolean jniDebugBuild,
com.android.builder.model.SigningConfig signingConfig,
com.android.builder.model.PackagingOptions packagingOptions,
java.lang.String outApkLocation)
Packages the apk. |
void |
preDexLibrary(java.io.File inputFile,
java.io.File outFile,
DexOptions dexOptions)
Converts the bytecode to Dalvik format |
static void |
preDexLibrary(java.io.File inputFile,
java.io.File outFile,
DexOptions dexOptions,
com.android.sdklib.BuildToolInfo buildToolInfo,
boolean verbose,
com.android.ide.common.internal.CommandLineRunner commandLineRunner)
|
void |
processManifest(java.io.File mainManifest,
java.util.List<java.io.File> manifestOverlays,
java.util.List<? extends ManifestDependency> libraries,
java.lang.String packageOverride,
int versionCode,
java.lang.String versionName,
java.lang.String minSdkVersion,
java.lang.String targetSdkVersion,
java.lang.String outManifestLocation)
Merges all the manifests into a single manifest |
void |
processResources(java.io.File manifestFile,
java.io.File resFolder,
java.io.File assetsDir,
java.util.List<? extends SymbolFileProvider> libraries,
java.lang.String packageForR,
java.lang.String sourceOutputDir,
java.lang.String symbolOutputDir,
java.lang.String resPackageOutput,
java.lang.String proguardOutput,
VariantConfiguration.Type type,
boolean debuggable,
com.android.builder.model.AaptOptions options,
java.util.Collection<java.lang.String> resourceConfigs,
boolean enforceUniquePackageName)
Process the resources and generate R.java and/or the packaged resources. |
void |
processTestManifest(java.lang.String testApplicationId,
java.lang.String minSdkVersion,
java.lang.String targetSdkVersion,
java.lang.String testedApplicationId,
java.lang.String instrumentationRunner,
java.lang.Boolean handleProfiling,
java.lang.Boolean functionalTest,
java.util.List<? extends ManifestDependency> libraries,
java.io.File outManifest)
Creates the manifest for a test variant |
void |
processTestManifest2(java.lang.String testApplicationId,
java.lang.String minSdkVersion,
java.lang.String targetSdkVersion,
java.lang.String testedApplicationId,
java.lang.String instrumentationRunner,
java.lang.Boolean handleProfiling,
java.lang.Boolean functionalTest,
java.io.File testManifestFile,
java.util.List<? extends ManifestDependency> libraries,
java.io.File outManifest,
java.io.File tmpDir)
Creates the manifest for a test variant |
void |
setTargetInfo(SdkInfo sdkInfo,
TargetInfo targetInfo)
Sets the SdkInfo and the targetInfo on the builder. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AndroidBuilder(@NonNull java.lang.String projectId, @Nullable java.lang.String createdBy, @NonNull com.android.utils.ILogger logger, boolean verboseExec)
createdBy
- the createdBy String for the apk manifest.logger
- the LoggerverboseExec
- whether external tools are launched in verbose modeMethod Detail |
---|
public void setTargetInfo(@NonNull SdkInfo sdkInfo, @NonNull TargetInfo targetInfo)
sdkInfo
- the SdkInfotargetInfo
- the TargetInfoSdkLoader
@Nullable public SdkInfo getSdkInfo()
@Nullable public TargetInfo getTargetInfo()
@Nullable public com.android.sdklib.IAndroidTarget getTarget()
public boolean isPreviewTarget()
public java.lang.String getTargetCodename()
@NonNull public java.util.List<java.lang.String> getBootClasspath()
@Nullable public java.io.File getRenderScriptSupportJar()
setTargetInfo(com.android.builder.sdk.SdkInfo, com.android.builder.sdk.TargetInfo)
@NonNull public java.util.Set<java.io.File> getCompileClasspath(@NonNull VariantConfiguration variantConfiguration)
@NonNull public java.util.Set<java.io.File> getPackagedJars(@NonNull VariantConfiguration variantConfiguration)
@Nullable public java.io.File getSupportNativeLibFolder()
setTargetInfo(com.android.builder.sdk.SdkInfo, com.android.builder.sdk.TargetInfo)
@NonNull public com.android.ide.common.internal.PngCruncher getAaptCruncher()
PngCruncher
using aapt underneath
@NonNull public com.android.ide.common.internal.CommandLineRunner getCommandLineRunner()
@NonNull public static com.android.builder.model.ClassField createClassField(@NonNull java.lang.String type, @NonNull java.lang.String name, @NonNull java.lang.String value)
public void mergeManifests(@NonNull java.io.File mainManifest, @NonNull java.util.List<java.io.File> manifestOverlays, @NonNull java.util.List<? extends ManifestDependency> libraries, java.lang.String packageOverride, int versionCode, java.lang.String versionName, @Nullable java.lang.String minSdkVersion, @Nullable java.lang.String targetSdkVersion, @Nullable java.lang.Integer maxSdkVersion, @NonNull java.lang.String outManifestLocation, com.android.manifmerger.ManifestMerger2.MergeType mergeType, java.util.Map<java.lang.String,java.lang.String> placeHolders)
public void processManifest(@NonNull java.io.File mainManifest, @NonNull java.util.List<java.io.File> manifestOverlays, @NonNull java.util.List<? extends ManifestDependency> libraries, java.lang.String packageOverride, int versionCode, java.lang.String versionName, @Nullable java.lang.String minSdkVersion, @Nullable java.lang.String targetSdkVersion, @NonNull java.lang.String outManifestLocation)
mainManifest
- The main manifest of the application.manifestOverlays
- manifest overlays coming from flavors and build typeslibraries
- the library dependency graphpackageOverride
- a package name override. Can be null.versionCode
- a version code to inject in the manifest or -1 to do nothing.versionName
- a version name to inject in the manifest or null to do nothing.minSdkVersion
- a minSdkVersion to inject in the manifest or -1 to do nothing.targetSdkVersion
- a targetSdkVersion to inject in the manifest or -1 to do nothing.outManifestLocation
- the output location for the merged manifestVariantConfiguration.getMainManifest()
,
VariantConfiguration.getManifestOverlays()
,
VariantConfiguration.getDirectLibraries()
,
VariantConfiguration.getMergedFlavor()
,
DefaultProductFlavor.getVersionCode()
,
DefaultProductFlavor.getVersionName()
,
DefaultProductFlavor.getMinSdkVersion()
,
DefaultProductFlavor.getTargetSdkVersion()
public void processTestManifest(@NonNull java.lang.String testApplicationId, @Nullable java.lang.String minSdkVersion, @Nullable java.lang.String targetSdkVersion, @NonNull java.lang.String testedApplicationId, @NonNull java.lang.String instrumentationRunner, @NonNull java.lang.Boolean handleProfiling, @NonNull java.lang.Boolean functionalTest, @NonNull java.util.List<? extends ManifestDependency> libraries, @NonNull java.io.File outManifest)
testApplicationId
- the application id of the test applicationminSdkVersion
- the minSdkVersion of the test applicationtargetSdkVersion
- the targetSdkVersion of the test applicationtestedApplicationId
- the application id of the tested applicationinstrumentationRunner
- the name of the instrumentation runnerhandleProfiling
- whether or not the Instrumentation object will turn profiling on and offfunctionalTest
- whether or not the Instrumentation class should run as a functional testlibraries
- the library dependency graphoutManifest
- the output location for the merged manifestVariantConfiguration.getApplicationId()
,
VariantConfiguration.getTestedConfig()
,
VariantConfiguration.getMinSdkVersion()
,
VariantConfiguration.getTestedApplicationId()
,
VariantConfiguration.getInstrumentationRunner()
,
VariantConfiguration.getHandleProfiling()
,
VariantConfiguration.getFunctionalTest()
,
VariantConfiguration.getDirectLibraries()
public void processTestManifest2(@NonNull java.lang.String testApplicationId, @Nullable java.lang.String minSdkVersion, @Nullable java.lang.String targetSdkVersion, @NonNull java.lang.String testedApplicationId, @NonNull java.lang.String instrumentationRunner, @NonNull java.lang.Boolean handleProfiling, @NonNull java.lang.Boolean functionalTest, @Nullable java.io.File testManifestFile, @NonNull java.util.List<? extends ManifestDependency> libraries, @NonNull java.io.File outManifest, @NonNull java.io.File tmpDir)
testApplicationId
- the application id of the test applicationminSdkVersion
- the minSdkVersion of the test applicationtargetSdkVersion
- the targetSdkVersion of the test applicationtestedApplicationId
- the application id of the tested applicationinstrumentationRunner
- the name of the instrumentation runnerhandleProfiling
- whether or not the Instrumentation object will turn profiling on and offfunctionalTest
- whether or not the Instrumentation class should run as a functional testtestManifestFile
- optionally user provided AndroidManifest.xml for testing applicationlibraries
- the library dependency graphoutManifest
- the output location for the merged manifestVariantConfiguration.getApplicationId()
,
VariantConfiguration.getTestedConfig()
,
VariantConfiguration.getMinSdkVersion()
,
VariantConfiguration.getTestedApplicationId()
,
VariantConfiguration.getInstrumentationRunner()
,
VariantConfiguration.getHandleProfiling()
,
VariantConfiguration.getFunctionalTest()
,
VariantConfiguration.getDirectLibraries()
public void processResources(@NonNull java.io.File manifestFile, @NonNull java.io.File resFolder, @Nullable java.io.File assetsDir, @Nullable java.util.List<? extends SymbolFileProvider> libraries, @Nullable java.lang.String packageForR, @Nullable java.lang.String sourceOutputDir, @Nullable java.lang.String symbolOutputDir, @Nullable java.lang.String resPackageOutput, @Nullable java.lang.String proguardOutput, VariantConfiguration.Type type, boolean debuggable, @NonNull com.android.builder.model.AaptOptions options, @NonNull java.util.Collection<java.lang.String> resourceConfigs, boolean enforceUniquePackageName) throws java.io.IOException, java.lang.InterruptedException, com.android.ide.common.internal.LoggedErrorException
manifestFile
- the location of the manifest fileresFolder
- the merged res folderassetsDir
- the merged asset folderlibraries
- the flat list of librariespackageForR
- Package override to generate the R class in a different package.sourceOutputDir
- optional source folder to generate R.javaresPackageOutput
- optional filepath for packaged resourcesproguardOutput
- optional filepath for proguard file to generatetype
- the type of the variant being builtdebuggable
- whether the app is debuggableoptions
- the AaptOptions
resourceConfigs
- a list of resource config filters to pass to aapt.enforceUniquePackageName
- if true method will fail if some libraries share the same
package name
java.io.IOException
java.lang.InterruptedException
com.android.ide.common.internal.LoggedErrorException
public void generateApkData(@NonNull java.io.File apkFile, @NonNull java.io.File outResFolder, @NonNull java.lang.String mainPkgName, @NonNull java.lang.String resName) throws java.lang.InterruptedException, com.android.ide.common.internal.LoggedErrorException, java.io.IOException
java.lang.InterruptedException
com.android.ide.common.internal.LoggedErrorException
java.io.IOException
public void generateApkDataEntryInManifest(@NonNull java.io.File manifestFile) throws java.lang.InterruptedException, com.android.ide.common.internal.LoggedErrorException, java.io.IOException
java.lang.InterruptedException
com.android.ide.common.internal.LoggedErrorException
java.io.IOException
public void compileAllAidlFiles(@NonNull java.util.List<java.io.File> sourceFolders, @NonNull java.io.File sourceOutputDir, @Nullable java.io.File parcelableOutputDir, @NonNull java.util.List<java.io.File> importFolders, @Nullable DependencyFileProcessor dependencyFileProcessor) throws java.io.IOException, java.lang.InterruptedException, com.android.ide.common.internal.LoggedErrorException
sourceFolders
- all the source folders to find files to compilesourceOutputDir
- the output dir in which to generate the source codeimportFolders
- import foldersdependencyFileProcessor
- the dependencyFileProcessor to record the dependencies
of the compilation.
java.io.IOException
java.lang.InterruptedException
com.android.ide.common.internal.LoggedErrorException
public void compileAidlFile(@NonNull java.io.File sourceFolder, @NonNull java.io.File aidlFile, @NonNull java.io.File sourceOutputDir, @Nullable java.io.File parcelableOutputDir, @NonNull java.util.List<java.io.File> importFolders, @Nullable DependencyFileProcessor dependencyFileProcessor) throws java.io.IOException, java.lang.InterruptedException, com.android.ide.common.internal.LoggedErrorException
aidlFile
- the AIDL file to compilesourceOutputDir
- the output dir in which to generate the source codeimportFolders
- all the import folders, including the source folders.dependencyFileProcessor
- the dependencyFileProcessor to record the dependencies
of the compilation.
java.io.IOException
java.lang.InterruptedException
com.android.ide.common.internal.LoggedErrorException
public void compileAllRenderscriptFiles(@NonNull java.util.List<java.io.File> sourceFolders, @NonNull java.util.List<java.io.File> importFolders, @NonNull java.io.File sourceOutputDir, @NonNull java.io.File resOutputDir, @NonNull java.io.File objOutputDir, @NonNull java.io.File libOutputDir, int targetApi, boolean debugBuild, int optimLevel, boolean ndkMode, boolean supportMode, @Nullable java.util.Set<java.lang.String> abiFilters) throws java.io.IOException, java.lang.InterruptedException, com.android.ide.common.internal.LoggedErrorException
sourceFolders
- all the source folders to find files to compileimportFolders
- all the import folders.sourceOutputDir
- the output dir in which to generate the source coderesOutputDir
- the output dir in which to generate the bitcode filetargetApi
- the target apidebugBuild
- whether the build is debugoptimLevel
- the optimization levelndkMode
- supportMode
- support mode flag to generate .so files.abiFilters
- ABI filters in case of support mode
java.io.IOException
java.lang.InterruptedException
com.android.ide.common.internal.LoggedErrorException
@NonNull public java.util.List<java.io.File> getLeafFolders(@NonNull java.lang.String extension, java.util.List<java.io.File>... importFolders)
extension
- the extension to search for.importFolders
- an array of list of root folders.
public void convertByteCode(@NonNull java.lang.Iterable<java.io.File> inputs, @NonNull java.lang.Iterable<java.io.File> preDexedLibraries, @NonNull java.io.File outDexFolder, @NonNull DexOptions dexOptions, @Nullable java.util.List<java.lang.String> additionalParameters, boolean incremental) throws java.io.IOException, java.lang.InterruptedException, com.android.ide.common.internal.LoggedErrorException
inputs
- the input filespreDexedLibraries
- the list of pre-dexed librariesoutDexFolder
- the location of the output folderdexOptions
- dex optionsadditionalParameters
- incremental
- true if it should attempt incremental dex if applicable
java.io.IOException
java.lang.InterruptedException
com.android.ide.common.internal.LoggedErrorException
public void preDexLibrary(@NonNull java.io.File inputFile, @NonNull java.io.File outFile, @NonNull DexOptions dexOptions) throws java.io.IOException, java.lang.InterruptedException, com.android.ide.common.internal.LoggedErrorException
inputFile
- the input fileoutFile
- the location of the output classes.dex filedexOptions
- dex options
java.io.IOException
java.lang.InterruptedException
com.android.ide.common.internal.LoggedErrorException
public static void preDexLibrary(@NonNull java.io.File inputFile, @NonNull java.io.File outFile, @NonNull DexOptions dexOptions, @NonNull com.android.sdklib.BuildToolInfo buildToolInfo, boolean verbose, @NonNull com.android.ide.common.internal.CommandLineRunner commandLineRunner) throws java.io.IOException, java.lang.InterruptedException, com.android.ide.common.internal.LoggedErrorException
java.io.IOException
java.lang.InterruptedException
com.android.ide.common.internal.LoggedErrorException
public void packageApk(@NonNull java.lang.String androidResPkgLocation, @NonNull java.io.File dexFolder, @NonNull java.util.Collection<java.io.File> packagedJars, @Nullable java.lang.String javaResourcesLocation, @Nullable java.util.Collection<java.io.File> jniLibsFolders, @Nullable java.util.Set<java.lang.String> abiFilters, boolean jniDebugBuild, @Nullable com.android.builder.model.SigningConfig signingConfig, @Nullable com.android.builder.model.PackagingOptions packagingOptions, @NonNull java.lang.String outApkLocation) throws DuplicateFileException, java.io.FileNotFoundException, com.android.ide.common.signing.KeytoolException, PackagerException, SigningException
androidResPkgLocation
- the location of the packaged resource filedexFolder
- the folder with the dex file.packagedJars
- the jars that are packaged (libraries + jar dependencies)javaResourcesLocation
- the processed Java resource folderjniLibsFolders
- the folders containing jni shared librariesabiFilters
- optional ABI filterjniDebugBuild
- whether the app should include jni debug datasigningConfig
- the signing configurationpackagingOptions
- the packaging optionsoutApkLocation
- location of the APK.
DuplicateFileException
java.io.FileNotFoundException
- if the store location was not found
com.android.ide.common.signing.KeytoolException
PackagerException
SigningException
- when the key cannot be read from the keystoreVariantConfiguration.getPackagedJars()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |