com.android.builder.core.AndroidBuilder Java Examples
The following examples show how to use
com.android.builder.core.AndroidBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TPatchDiffResAPBuildTask.java From atlas with Apache License 2.0 | 6 votes |
private Aapt makeAapt(AaptGeneration aaptGeneration) throws IOException { AndroidBuilder builder = getBuilder(); MergingLog mergingLog = new MergingLog(mergeBlameLogFolder); ProcessOutputHandler processOutputHandler = new ParsingProcessOutputHandler( new ToolOutputParser( aaptGeneration == AaptGeneration.AAPT_V1 ? new AaptOutputParser() : new Aapt2OutputParser(), getILogger()), new MergingLogRewriter(mergingLog::find, builder.getErrorReporter())); return AaptGradleFactory.make( aaptGeneration, builder, processOutputHandler, fileCache, true, com.android.utils.FileUtils.mkdirs(new File(appVariantContext.getScope().getIncrementalDir(getName()), "aapt-temp")), aaptOptions.getCruncherProcesses()); }
Example #2
Source File: AppPlugin.java From javaide with GNU General Public License v3.0 | 6 votes |
@Override protected TaskManager createTaskManager( Project project, AndroidBuilder androidBuilder, AndroidConfig extension, SdkHandler sdkHandler, DependencyManager dependencyManager, ToolingModelBuilderRegistry toolingRegistry) { return new ApplicationTaskManager( project, androidBuilder, extension, sdkHandler, dependencyManager, toolingRegistry); }
Example #3
Source File: ProductFlavor.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * Adds a new field to the generated BuildConfig class. * <p> * The field is generated as: * <p> * <type> <name> = <value>; * <p> * This means each of these must have valid Java content. If the type is a String, then the * value should include quotes. * * @param type the type of the field * @param name the name of the field * @param value the value of the field */ public void buildConfigField( @NonNull String type, @NonNull String name, @NonNull String value) { ClassField alreadyPresent = getBuildConfigFields().get(name); if (alreadyPresent != null) { String flavorName = getName(); if (BuilderConstants.MAIN.equals(flavorName)) { logger.info( "DefaultConfig: buildConfigField '{}' value is being replaced: {} -> {}", name, alreadyPresent.getValue(), value); } else { logger.info( "ProductFlavor({}): buildConfigField '{}' " + "value is being replaced: {} -> {}", flavorName, name, alreadyPresent.getValue(), value); } } addBuildConfigField(AndroidBuilder.createClassField(type, name, value)); }
Example #4
Source File: ProcessManifest.java From javaide with GNU General Public License v3.0 | 6 votes |
@Override public void execute(@NonNull ProcessManifest processManifest) { final VariantConfiguration config = scope.getVariantConfiguration(); final AndroidBuilder androidBuilder = scope.getGlobalScope().getAndroidBuilder(); // get single output for now. final BaseVariantOutputData variantOutputData = scope.getVariantData().getOutputs().get(0); variantOutputData.manifestProcessorTask = processManifest; processManifest.setAndroidBuilder(androidBuilder); processManifest.setVariantName(config.getFullName()); processManifest.setVariantConfiguration(config); final ProductFlavor mergedFlavor = config.getMergedFlavor(); processManifest.setMinSdkVersion(getMinSdkVersion(androidBuilder, mergedFlavor, processManifest)); processManifest.setTargetSdkVersion(getTargetSdkVersion(androidBuilder, mergedFlavor, processManifest)); processManifest.setMaxSdkVersion(getMaxSdkVersion(androidBuilder, mergedFlavor)); processManifest.setManifestOutputFile(variantOutputData.getScope().getManifestOutputFile()); processManifest.setAaptFriendlyManifestOutputFile( new File(scope.getGlobalScope().getIntermediatesDir(), TaskManager.DIR_BUNDLES + "/" + config.getDirName() + "/aapt/AndroidManifest.xml")); }
Example #5
Source File: ProductFlavor.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * Adds a new generated resource. * <p> * <p>This is equivalent to specifying a resource in res/values. * <p> * <p>See <a href="http://developer.android.com/guide/topics/resources/available-resources.html">Resource Types</a>. * * @param type the type of the resource * @param name the name of the resource * @param value the value of the resource */ public void resValue( @NonNull String type, @NonNull String name, @NonNull String value) { ClassField alreadyPresent = getResValues().get(name); if (alreadyPresent != null) { String flavorName = getName(); if (BuilderConstants.MAIN.equals(flavorName)) { logger.info( "DefaultConfig: resValue '{}' value is being replaced: {} -> {}", name, alreadyPresent.getValue(), value); } else { logger.info( "ProductFlavor({}): resValue '{}' value is being replaced: {} -> {}", flavorName, name, alreadyPresent.getValue(), value); } } addResValue(AndroidBuilder.createClassField(type, name, value)); }
Example #6
Source File: ZipAlignUtils.java From atlas with Apache License 2.0 | 6 votes |
public static synchronized File doZipAlign(final AndroidBuilder androidBuilder, Project project, final File apkFile) { final File zipalignedFile = new File(apkFile.getParent(), apkFile.getName().replace(".apk", "-zipaligned.apk")); project.exec(new Action<ExecSpec>() { @Override public void execute(ExecSpec execSpec) { String path = androidBuilder.getTargetInfo() .getBuildTools().getPath(ZIP_ALIGN); execSpec.executable(new File(path)); execSpec.args("-f", "4"); execSpec.args(apkFile); execSpec.args(zipalignedFile); } }); return zipalignedFile; }
Example #7
Source File: VariantManager.java From javaide with GNU General Public License v3.0 | 6 votes |
public VariantManager( @NonNull Project project, @NonNull AndroidBuilder androidBuilder, @NonNull AndroidConfig extension, @NonNull VariantFactory variantFactory, @NonNull TaskManager taskManager, @NonNull Instantiator instantiator) { this.extension = extension; this.androidBuilder = androidBuilder; this.project = project; this.variantFactory = variantFactory; this.taskManager = taskManager; this.instantiator = instantiator; DefaultAndroidSourceSet mainSourceSet = (DefaultAndroidSourceSet) extension.getSourceSets().getByName(extension.getDefaultConfig().getName()); defaultConfigData = new ProductFlavorData<>( extension.getDefaultConfig(), mainSourceSet, project); signingOverride = createSigningOverride(); }
Example #8
Source File: GlobalScope.java From javaide with GNU General Public License v3.0 | 6 votes |
public GlobalScope( @NonNull Project project, @NonNull AndroidBuilder androidBuilder, @NonNull String projectBaseName, @NonNull AndroidConfig extension, @NonNull SdkHandler sdkHandler, @NonNull ToolingModelBuilderRegistry toolingRegistry) { this.project = project; this.androidBuilder = androidBuilder; this.projectBaseName = projectBaseName; this.extension = extension; this.sdkHandler = sdkHandler; this.toolingRegistry = toolingRegistry; intermediatesDir = new File(getBuildDir(), FD_INTERMEDIATES); generatedDir = new File(getBuildDir(), FD_GENERATED); reportsDir = new File(getBuildDir(), FD_REPORTS); outputsDir = new File(getBuildDir(), FD_OUTPUTS); }
Example #9
Source File: BuildHelper.java From atlas with Apache License 2.0 | 6 votes |
public static synchronized File doZipAlign(final AndroidBuilder androidBuilder, Project project, final File apkFile) { final File zipalignedFile = new File(apkFile.getParent(), apkFile.getName().replace(".apk", "-zipaligned.apk")); project.exec(new Action<ExecSpec>() { @Override public void execute(ExecSpec execSpec) { String path = androidBuilder.getTargetInfo() .getBuildTools().getPath(ZIP_ALIGN); execSpec.executable(new File(path)); execSpec.args("-f", "4"); execSpec.args(apkFile); execSpec.args(zipalignedFile); } }); return zipalignedFile; }
Example #10
Source File: AtlasConfigurationHelper.java From atlas with Apache License 2.0 | 6 votes |
public void createBuilderAfterEvaluate() throws Exception { AndroidBuilder androidBuilder = appPluginHook.getAndroidBuilder(); if (null == androidBuilder) { return; } AndroidBuilder atlasBuilder = new AtlasBuilder(project.equals(project.getRootProject()) ? project .getName() : project.getPath(), creator, new GradleProcessExecutor(project), new GradleJavaProcessExecutor(project), DefaultGroovyMethods.asType(ReflectUtils.getField( androidBuilder, "mErrorReporter"), ErrorReporter.class), LoggerWrapper.getLogger(AtlasBuilder.class), DefaultGroovyMethods.asType(ReflectUtils.getField( androidBuilder, "mVerboseExec"), Boolean.class)); ((AtlasBuilder) atlasBuilder).setDefaultBuilder(androidBuilder); ((AtlasBuilder) atlasBuilder).setAtlasExtension(atlasExtension); AtlasBuildContext.androidBuilderMap.put(project, (AtlasBuilder) (atlasBuilder)); }
Example #11
Source File: AwbApkPackageTask.java From atlas with Apache License 2.0 | 6 votes |
public AwbApkPackageTask(FileCollection resourceFiles, VariantContext variantContext, AwbBundle awbBundle, AppVariantOutputContext appVariantOutputContext, FileCollection dexFolders, FileCollection javaResouresFiles, FileCollection assets, FileCollection jniFolders, FileCollection awbManifestFolder, AndroidBuilder androidBuilder, int miniSdkVersion, String taskName) { this.packagingScope = new DefaultGradlePackagingScope(variantContext.getScope()); this.resourceFiles = resourceFiles; this.outputScope = variantContext.getScope().getOutputScope(); this.awbBundle = awbBundle; this.appVariantOutputContext = appVariantOutputContext; this.outputDirectory = ((AppVariantContext) variantContext).getAwbApkOutputDir(); this.dexFolders = dexFolders; this.javaResouresFiles = javaResouresFiles; this.assets = assets; this.jniFolders = jniFolders; this.awbManifestFolder = awbManifestFolder; this.instantRunContext = packagingScope.getInstantRunBuildContext(); this.signingConfig = packagingScope.getSigningConfig(); this.androidBuilder = androidBuilder; this.miniSdkVersion = miniSdkVersion; this.debug = packagingScope.isDebuggable(); supportAbis = packagingScope.getSupportedAbis(); this.jniDebug = packagingScope.isJniDebuggable(); aaptOptionsNoCompress = packagingScope.getAaptOptions().getNoCompress(); this.taskName = taskName; }
Example #12
Source File: TaskManager.java From javaide with GNU General Public License v3.0 | 6 votes |
public TaskManager( Project project, AndroidBuilder androidBuilder, AndroidConfig extension, SdkHandler sdkHandler, DependencyManager dependencyManager, ToolingModelBuilderRegistry toolingRegistry) { this.project = project; this.androidBuilder = androidBuilder; this.sdkHandler = sdkHandler; this.extension = extension; this.toolingRegistry = toolingRegistry; this.dependencyManager = dependencyManager; logger = Logging.getLogger(this.getClass()); globalScope = new GlobalScope( project, androidBuilder, checkNotNull((String) project.getProperties().get("archivesBaseName")), extension, sdkHandler, toolingRegistry); }
Example #13
Source File: AwoInstaller.java From atlas with Apache License 2.0 | 6 votes |
/** * todo how know which app will be debugged? * just support taobao.apk now */ private static void notifyApppatching(AndroidBuilder androidBuilder, String patchPkg, Logger logger) { CommandExecutor executor = CommandExecutor.Factory.createDefaultCommmandExecutor(); executor.setLogger(logger); executor.setCaptureStdOut(true); executor.setCaptureStdErr(true); // List<String> killCmd = Arrays.asList("shell", "am", "force-stop", packageNameForPatch); // List<String> startCmd = Arrays.asList("shell", "am", "start", packageNameForPatch + "/" + // launcherActivityForPatch); List<String> patchCmd = Arrays.asList("shell", "am", "broadcast", "-a", "com.taobao.atlas.intent.PATCH_APP", "-e", "pkg", patchPkg, "-n", patchPkg + "/com.taobao.atlas.update.AwoPatchReceiver"); try { executor.executeCommand(androidBuilder.getSdkInfo().getAdb().getAbsolutePath(), patchCmd, false); } catch (Exception e) { throw new RuntimeException("error while restarting app,you can also restart by yourself", e); } }
Example #14
Source File: ProcessAwbAndroidResources.java From atlas with Apache License 2.0 | 6 votes |
private Aapt makeAapt() throws IOException { AndroidBuilder builder = getBuilder(); MergingLog mergingLog = new MergingLog(getMergeBlameLogFolder()); FileCache fileCache = appVariantContext.getScope().getGlobalScope().getBuildCache(); ProcessOutputHandler processOutputHandler = new ParsingProcessOutputHandler( new ToolOutputParser( aaptGeneration == AaptGeneration.AAPT_V1 ? new AaptOutputParser() : new Aapt2OutputParser(), getILogger()), new MergingLogRewriter(mergingLog::find, builder.getErrorReporter())); return AaptGradleFactory.make( aaptGeneration, builder, processOutputHandler, fileCache, true, FileUtils.mkdirs(new File(getIncrementalFolder(), "awb-aapt-temp/"+awbBundle.getName())), aaptOptions.getCruncherProcesses()); }
Example #15
Source File: ApplicationVariantFactory.java From javaide with GNU General Public License v3.0 | 5 votes |
public ApplicationVariantFactory( @NonNull Instantiator instantiator, @NonNull AndroidBuilder androidBuilder, @NonNull AndroidConfig extension) { this.instantiator = instantiator; this.androidBuilder = androidBuilder; this.extension = extension; }
Example #16
Source File: BaseComponentModelPlugin.java From javaide with GNU General Public License v3.0 | 5 votes |
@Model(ANDROID_BUILDER) public AndroidBuilder createAndroidBuilder(Project project, ExtraModelInfo extraModelInfo) { String creator = "Android Gradle"; ILogger logger = new LoggerWrapper(project.getLogger()); return new AndroidBuilder(project.equals(project.getRootProject()) ? project.getName() : project.getPath(), creator, new GradleProcessExecutor(project), new GradleJavaProcessExecutor(project), extraModelInfo, logger, project.getLogger().isEnabled(LogLevel.INFO)); }
Example #17
Source File: BaseComponentModelPlugin.java From javaide with GNU General Public License v3.0 | 5 votes |
public void createAndroidComponents( ComponentSpecContainer androidSpecs, ServiceRegistry serviceRegistry, AndroidConfig androidExtension, com.android.build.gradle.AndroidConfig adaptedModel, @Path("android.buildTypes") ModelMap<BuildType> buildTypes, @Path("android.productFlavors") ModelMap<ProductFlavor> productFlavors, @Path("android.signingConfigs") ModelMap<SigningConfig> signingConfigs, VariantFactory variantFactory, TaskManager taskManager, Project project, AndroidBuilder androidBuilder, SdkHandler sdkHandler, ExtraModelInfo extraModelInfo, @Path("isApplication") Boolean isApplication) { Instantiator instantiator = serviceRegistry.get(Instantiator.class); // check if the target has been set. TargetInfo targetInfo = androidBuilder.getTargetInfo(); if (targetInfo == null) { sdkHandler.initTarget(androidExtension.getCompileSdkVersion(), androidExtension.getBuildToolsRevision(), androidExtension.getLibraryRequests(), androidBuilder); } VariantManager variantManager = new VariantManager(project, androidBuilder, adaptedModel, variantFactory, taskManager, instantiator); for (BuildType buildType : buildTypes.values()) { variantManager.addBuildType(new BuildTypeAdaptor(buildType)); } for (ProductFlavor productFlavor : productFlavors.values()) { variantManager.addProductFlavor(new ProductFlavorAdaptor(productFlavor)); } DefaultAndroidComponentSpec spec = (DefaultAndroidComponentSpec) androidSpecs.get(COMPONENT_NAME); spec.setExtension(androidExtension); spec.setVariantManager(variantManager); }
Example #18
Source File: BasePlugin.java From javaide with GNU General Public License v3.0 | 5 votes |
protected abstract TaskManager createTaskManager( Project project, AndroidBuilder androidBuilder, AndroidConfig extension, SdkHandler sdkHandler, DependencyManager dependencyManager, ToolingModelBuilderRegistry toolingRegistry);
Example #19
Source File: BasePlugin.java From javaide with GNU General Public License v3.0 | 5 votes |
protected void configureProject() { extraModelInfo = new ExtraModelInfo(project, isLibrary()); sdkHandler = new SdkHandler(project, getLogger()); androidBuilder = new AndroidBuilder( project == project.getRootProject() ? project.getName() : project.getPath(), "Android Gradle Java N-IDE", new GradleProcessExecutor(project), new GradleJavaProcessExecutor(project), extraModelInfo, getLogger(), isVerbose()); // project.getPlugins().apply(JavaBasePlugin.class); // call back on execution. This is called after the whole build is done (not // after the current project is done). // This is will be called for each (android) projects though, so this should support // being called 2+ times. project.getGradle().getTaskGraph().addTaskExecutionGraphListener( new TaskExecutionGraphListener() { @Override public void graphPopulated(TaskExecutionGraph taskGraph) { for (Task task : taskGraph.getAllTasks()) { if (task instanceof PreDex) { PreDexCache.getCache().load( new File(project.getRootProject().getBuildDir(), FD_INTERMEDIATES + "/dex-cache/cache.xml")); break; } } } }); }
Example #20
Source File: LibraryVariantImpl.java From javaide with GNU General Public License v3.0 | 5 votes |
public LibraryVariantImpl( @NonNull LibraryVariantData variantData, @NonNull AndroidBuilder androidBuilder, @NonNull ReadOnlyObjectProvider readOnlyObjectProvider) { super(androidBuilder, readOnlyObjectProvider); this.variantData = variantData; }
Example #21
Source File: LibraryTaskManager.java From javaide with GNU General Public License v3.0 | 5 votes |
public LibraryTaskManager( Project project, AndroidBuilder androidBuilder, AndroidConfig extension, SdkHandler sdkHandler, DependencyManager dependencyManager, ToolingModelBuilderRegistry toolingRegistry) { super(project, androidBuilder, extension, sdkHandler, dependencyManager, toolingRegistry); }
Example #22
Source File: ApplicationVariantImpl.java From javaide with GNU General Public License v3.0 | 5 votes |
public ApplicationVariantImpl( @NonNull ApplicationVariantData variantData, @NonNull AndroidBuilder androidBuilder, @NonNull ReadOnlyObjectProvider readOnlyObjectProvider) { super(androidBuilder, readOnlyObjectProvider); this.variantData = variantData; }
Example #23
Source File: LibraryVariantFactory.java From javaide with GNU General Public License v3.0 | 5 votes |
public LibraryVariantFactory( @NonNull Instantiator instantiator, @NonNull AndroidBuilder androidBuilder, @NonNull AndroidConfig extension) { this.instantiator = instantiator; this.androidBuilder = androidBuilder; this.extension = extension; }
Example #24
Source File: ApiObjectFactory.java From javaide with GNU General Public License v3.0 | 5 votes |
public ApiObjectFactory( @NonNull AndroidBuilder androidBuilder, @NonNull BaseExtension extension, @NonNull VariantFactory variantFactory, @NonNull Instantiator instantiator) { this.androidBuilder = androidBuilder; this.extension = extension; this.variantFactory = variantFactory; this.instantiator = instantiator; }
Example #25
Source File: ModelBuilder.java From javaide with GNU General Public License v3.0 | 5 votes |
public ModelBuilder( @NonNull AndroidBuilder androidBuilder, @NonNull VariantManager variantManager, @NonNull TaskManager taskManager, @NonNull AndroidConfig config, @NonNull ExtraModelInfo extraModelInfo, boolean isLibrary) { this.androidBuilder = androidBuilder; this.config = config; this.extraModelInfo = extraModelInfo; this.variantManager = variantManager; this.taskManager = taskManager; this.isLibrary = isLibrary; }
Example #26
Source File: BuildType.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Adds a new generated resource. * * @param type the type of the resource * @param name the name of the resource * @param value the value of the resource */ public void resValue( @NonNull String type, @NonNull String name, @NonNull String value) { ClassField alreadyPresent = getResValues().get(name); if (alreadyPresent != null) { logger.info("BuildType({}): resValue '{}' value is being replaced: {} -> {}", getName(), name, alreadyPresent.getValue(), value); } addResValue(AndroidBuilder.createClassField(type, name, value)); }
Example #27
Source File: ProcessManifest.java From javaide with GNU General Public License v3.0 | 5 votes |
private Integer getMaxSdkVersion(AndroidBuilder androidBuilder, ProductFlavor mergedFlavor) { if (androidBuilder.isPreviewTarget()) { return null; } return mergedFlavor.getMaxSdkVersion(); }
Example #28
Source File: BaseTask.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Returns the androidBuilder. * * @throws IllegalStateException if androidBuilder has not been set, */ @NonNull protected AndroidBuilder getBuilder() { Preconditions.checkState(androidBuilder != null, "androidBuilder required for task '%s'.", getName()); return androidBuilder; }
Example #29
Source File: SdkHandler.java From javaide with GNU General Public License v3.0 | 5 votes |
public void initTarget( @NonNull String targetHash, @NonNull FullRevision buildToolRevision, @NonNull Collection<LibraryRequest> usedLibraries, @NonNull AndroidBuilder androidBuilder) { Preconditions.checkNotNull(targetHash, "android.compileSdkVersion is missing!"); Preconditions.checkNotNull(buildToolRevision, "android.buildToolsVersion is missing!"); SdkLoader sdkLoader = getSdkLoader(); SdkInfo sdkInfo = sdkLoader.getSdkInfo(logger); TargetInfo targetInfo = sdkLoader.getTargetInfo(targetHash, buildToolRevision, logger); androidBuilder.setTargetInfo(sdkInfo, targetInfo, usedLibraries); }
Example #30
Source File: AppExtension.java From javaide with GNU General Public License v3.0 | 5 votes |
public AppExtension(@NonNull ProjectInternal project, @NonNull Instantiator instantiator, @NonNull AndroidBuilder androidBuilder, @NonNull SdkHandler sdkHandler, @NonNull NamedDomainObjectContainer<BuildType> buildTypes, @NonNull NamedDomainObjectContainer<ProductFlavor> productFlavors, @NonNull NamedDomainObjectContainer<SigningConfig> signingConfigs, @NonNull ExtraModelInfo extraModelInfo, boolean isLibrary) { super(project, instantiator, androidBuilder, sdkHandler, buildTypes, productFlavors, signingConfigs, extraModelInfo, isLibrary); }