use of com.android.builder.core.AndroidBuilder in project atlas by alibaba.
the class AtlasConfigurationHelper method createBuilderAfterEvaluate.
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));
}
use of com.android.builder.core.AndroidBuilder in project atlas by alibaba.
the class AppPluginHook method getAndroidBuilder.
// public void replaceTaskManager() throws Exception {
//
// AppPlugin appPlugin = project.getPlugins().findPlugin(AppPlugin.class);
//
// if (null == appPlugin) {
// return;
// }
//
// TaskManager taskManager =
// (TaskManager)ReflectUtils.getField(BasePlugin.class, appPlugin, "taskManager");
//
// DependencyManager dependencyManager = (DependencyManager)ReflectUtils.getField(TaskManager.class, taskManager,
// "dependencyManager");
//
// AtlasDependencyManager atlasDependencyManager = new AtlasDependencyManager(project,
// (ExtraModelInfo)ReflectUtils
// .getField(dependencyManager,
// "extraModelInfo"),
// (SdkHandler)ReflectUtils
// .getField(dependencyManager,
// "sdkHandler"));
//
// ReflectUtils.updateField(TaskManager.class, taskManager, "dependencyManager", atlasDependencyManager);
//
// }
public AndroidBuilder getAndroidBuilder() throws Exception {
BasePlugin basePlugin = project.getPlugins().findPlugin(AppPlugin.class);
if (null == basePlugin) {
basePlugin = project.getPlugins().findPlugin(LibraryPlugin.class);
}
if (null == basePlugin) {
return null;
}
AndroidBuilder androidBuilder = (AndroidBuilder) ReflectUtils.getField(BasePlugin.class, basePlugin, "androidBuilder");
return androidBuilder;
}
use of com.android.builder.core.AndroidBuilder in project atlas by alibaba.
the class ProcessAwbAndroidResources method makeAapt.
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());
}
use of com.android.builder.core.AndroidBuilder in project atlas by alibaba.
the class BasePlugin method configureProject.
protected void configureProject() {
extraModelInfo = new ExtraModelInfo(project, isLibrary());
checkGradleVersion();
sdkHandler = new SdkHandler(project, getLogger());
project.afterEvaluate(p -> {
if (!p.getGradle().getStartParameter().isOffline() && AndroidGradleOptions.getUseSdkDownload(p)) {
SdkLibData sdkLibData = SdkLibData.download(getDownloader(), getSettingsController());
dependencyManager.setSdkLibData(sdkLibData);
sdkHandler.setSdkLibData(sdkLibData);
}
});
androidBuilder = new AndroidBuilder(project == project.getRootProject() ? project.getName() : project.getPath(), creator, new GradleProcessExecutor(project), new GradleJavaProcessExecutor(project), extraModelInfo, getLogger(), isVerbose());
dataBindingBuilder = new DataBindingBuilder();
dataBindingBuilder.setPrintMachineReadableOutput(extraModelInfo.getErrorFormatMode() == ExtraModelInfo.ErrorFormatMode.MACHINE_PARSABLE);
project.getPlugins().apply(JavaBasePlugin.class);
jacocoPlugin = project.getPlugins().apply(JacocoPlugin.class);
project.getTasks().getByName("assemble").setDescription("Assembles all variants of all applications and secondary packages.");
// 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().addBuildListener(new BuildListener() {
private final LibraryCache libraryCache = LibraryCache.getCache();
@Override
public void buildStarted(Gradle gradle) {
}
@Override
public void settingsEvaluated(Settings settings) {
}
@Override
public void projectsLoaded(Gradle gradle) {
}
@Override
public void projectsEvaluated(Gradle gradle) {
}
@Override
public void buildFinished(BuildResult buildResult) {
ExecutorSingleton.shutdown();
sdkHandler.unload();
ThreadRecorder.get().record(ExecutionType.BASE_PLUGIN_BUILD_FINISHED, project.getPath(), null, new Recorder.Block() {
@Override
public Void call() throws Exception {
PreDexCache.getCache().clear(new File(project.getRootProject().getBuildDir(), FD_INTERMEDIATES + "/dex-cache/cache.xml"), getLogger());
JackConversionCache.getCache().clear(new File(project.getRootProject().getBuildDir(), FD_INTERMEDIATES + "/jack-cache/cache.xml"), getLogger());
libraryCache.unload();
Main.clearInternTables();
return null;
}
});
}
});
project.getGradle().getTaskGraph().addTaskExecutionGraphListener(new TaskExecutionGraphListener() {
@Override
public void graphPopulated(TaskExecutionGraph taskGraph) {
for (Task task : taskGraph.getAllTasks()) {
if (task instanceof TransformTask) {
Transform transform = ((TransformTask) task).getTransform();
if (transform instanceof DexTransform) {
PreDexCache.getCache().load(new File(project.getRootProject().getBuildDir(), FD_INTERMEDIATES + "/dex-cache/cache.xml"));
break;
} else if (transform instanceof JackPreDexTransform) {
JackConversionCache.getCache().load(new File(project.getRootProject().getBuildDir(), FD_INTERMEDIATES + "/jack-cache/cache.xml"));
break;
}
}
}
}
});
}
use of com.android.builder.core.AndroidBuilder in project atlas by alibaba.
the class TPatchDiffResAPBuildTask method makeAapt.
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());
}
Aggregations