use of org.gradle.api.initialization.Settings in project atlas by alibaba.
the class AtlasPlugin method configurePlugin.
/**
* 启动设置插件
*/
private void configurePlugin() {
creator = "Atlas Gradle PLUGIN";
extraModelInfo = new ExtraModelInfo(project, PluginTypeUtils.isLibraryProject(project));
prepareBuildTools(project, extraModelInfo, atlasExtension.getTBuildConfig().getUseCustomAapt());
tAndroidBuilder = AtlasBuildContext.androidBuilder;
sdkHandler = new SdkHandler(project, getLogger());
AndroidConfig extension = DefaultGroovyMethods.asType(DefaultGroovyMethods.getAt(project.getExtensions(), "android"), AndroidConfig.class);
sdkHandler.initTarget(extension.getCompileSdkVersion(), extension.getBuildToolsRevision(), extension.getLibraryRequests(), tAndroidBuilder, SdkHandler.useCachedSdk(project));
project.getGradle().addBuildListener(new BuildListener() {
@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) {
sdkHandler.unload();
}
private final LibraryCache libraryCache = LibraryCache.getCache();
});
}
use of org.gradle.api.initialization.Settings 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;
}
}
}
}
});
}
Aggregations