use of org.gradle.BuildAdapter in project gradle by gradle.
the class ScalaBasePlugin method configureScalaCompile.
private static void configureScalaCompile(final Project project, JavaBasePlugin javaPlugin, final SourceSet sourceSet) {
String taskName = sourceSet.getCompileTaskName("scala");
final ScalaCompile scalaCompile = project.getTasks().create(taskName, ScalaCompile.class);
scalaCompile.dependsOn(sourceSet.getCompileJavaTaskName());
javaPlugin.configureForSourceSet(sourceSet, scalaCompile);
Convention scalaConvention = (Convention) InvokerHelper.getProperty(sourceSet, "convention");
ScalaSourceSet scalaSourceSet = scalaConvention.findPlugin(ScalaSourceSet.class);
scalaCompile.setDescription("Compiles the " + scalaSourceSet.getScala() + ".");
scalaCompile.setSource(scalaSourceSet.getScala());
project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(taskName);
// cannot use convention mapping because the resulting object won't be serializable
// cannot compute at task execution time because we need association with source set
project.getGradle().addBuildListener(new BuildAdapter() {
@Override
public void projectsEvaluated(Gradle gradle) {
IncrementalCompileOptions incrementalOptions = scalaCompile.getScalaCompileOptions().getIncrementalOptions();
if (incrementalOptions.getAnalysisFile() == null) {
String analysisFilePath = project.getBuildDir().getPath() + "/tmp/scala/compilerAnalysis/" + scalaCompile.getName() + ".analysis";
incrementalOptions.setAnalysisFile(new File(analysisFilePath));
}
if (incrementalOptions.getPublishedCode() == null) {
Jar jarTask = (Jar) project.getTasks().findByName(sourceSet.getJarTaskName());
incrementalOptions.setPublishedCode(jarTask == null ? null : jarTask.getArchivePath());
}
}
});
}
use of org.gradle.BuildAdapter in project gradle by gradle.
the class ClientProvidedBuildActionRunner method run.
@Override
public void run(BuildAction action, final BuildController buildController) {
if (!(action instanceof ClientProvidedBuildAction)) {
return;
}
final GradleInternal gradle = buildController.getGradle();
gradle.getStartParameter().setConfigureOnDemand(false);
ClientProvidedBuildAction clientProvidedBuildAction = (ClientProvidedBuildAction) action;
PayloadSerializer payloadSerializer = getPayloadSerializer(gradle);
final Object clientAction = payloadSerializer.deserialize(clientProvidedBuildAction.getAction());
gradle.addBuildListener(new BuildAdapter() {
@Override
public void buildFinished(BuildResult result) {
if (result.getFailure() == null) {
buildController.setResult(buildResult(clientAction, gradle));
}
}
});
if (clientProvidedBuildAction.isRunTasks()) {
buildController.run();
} else {
buildController.configure();
}
}
use of org.gradle.BuildAdapter in project gradle by gradle.
the class DependencyManagementGradleUserHomeScopeServices method createArtifactCaches.
ArtifactCachesProvider createArtifactCaches(GlobalScopedCache globalScopedCache, CacheRepository cacheRepository, DefaultArtifactCaches.WritableArtifactCacheLockingParameters parameters, ListenerManager listenerManager, DocumentationRegistry documentationRegistry) {
DefaultArtifactCaches artifactCachesProvider = new DefaultArtifactCaches(globalScopedCache, cacheRepository, parameters, documentationRegistry);
listenerManager.addListener(new BuildAdapter() {
@SuppressWarnings("deprecation")
@Override
public void buildFinished(BuildResult result) {
artifactCachesProvider.getWritableCacheLockingManager().useCache(() -> {
// forces cleanup even if cache wasn't used
});
}
});
return artifactCachesProvider;
}
Aggregations