use of org.gradle.jvm.toolchain.JavaToolchainService in project gradle by gradle.
the class GroovyBasePlugin method getToolchainTool.
private <T> Provider<T> getToolchainTool(Project project, BiFunction<JavaToolchainService, JavaToolchainSpec, Provider<T>> toolMapper) {
final JavaPluginExtension extension = extensionOf(project, JavaPluginExtension.class);
final JavaToolchainService service = extensionOf(project, JavaToolchainService.class);
return toolMapper.apply(service, extension.getToolchain());
}
use of org.gradle.jvm.toolchain.JavaToolchainService in project webpieces by deanhiller.
the class TemplateCompilerPlugin method configureSourceSetDefaults.
private void configureSourceSetDefaults(Project project) {
log.debug("setup configure source set defaults");
JavaPluginExtension javaPluginExtension = javaPluginExtension();
// SourceSetContainer sourceSets = javaPluginExtension.getSourceSets();
// SourceSet main = sourceSets.findByName(SourceSet.MAIN_SOURCE_SET_NAME);
// SourceSet test = sourceSets.findByName(SourceSet.TEST_SOURCE_SET_NAME);
//
// test.setRuntimeClasspath(project.getObjects().fileCollection().from(test.getOutput(), main.getOutput(), project.getConfigurations().getByName(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME)));
// // Register the project's source set output directories
// sourceSets.all(sourceSet ->
// buildOutputCleanupRegistry.registerOutputs(sourceSet.getOutput())
// );
javaPluginExtension.getSourceSets().all(sourceSet -> {
String name = "templates";
final DefaultTemplateSourceSet groovySourceSet = new DefaultTemplateSourceSet(name, ((DefaultSourceSet) sourceSet).getDisplayName(), objectFactory);
(new DslObject(sourceSet)).getConvention().getPlugins().put("templates", groovySourceSet);
// copied from JavaBasePlugin
processCopyTemplateResources(project, sourceSet);
// sourceSet.getExtensions().add(GroovySourceDirectorySet.class, "groovy", groovySourceSet.getGroovy()); //We do not need this one
SourceDirectorySet groovySource = groovySourceSet.getTemplateDirSet();
groovySource.srcDir("src/" + sourceSet.getName() + "/java");
sourceSet.getResources().getFilter().exclude(SerializableLambdas.spec((element) -> {
return groovySource.contains(element.getFile());
}));
sourceSet.getAllJava().source(groovySource);
sourceSet.getAllSource().source(groovySource);
// copy over but comment as I think no longer needed anymore
// NEEDED?: configureOutputDirectoryForSourceSet(sourceSet, groovySourceSet.getTemplateDirSet(), project);
final TaskProvider<TemplateCompile> compileTask = project.getTasks().register(sourceSet.getCompileTaskName("templates"), TemplateCompile.class, compile -> {
JvmPluginsHelper.configureForSourceSet(sourceSet, groovySource, compile, compile.getOptions(), project);
// copy over but comment as I think no longer needed anymore
// NEEDED?: compile.dependsOn(sourceSet.getCompileJavaTaskName());
compile.setDescription("Compiles the " + sourceSet.getName() + " Webpieces Templates.");
compile.setSource(groovySource);
// copy over but comment as I think no longer needed anymore
// NEEDED?: compile.setDestinationDir(new File(project.getBuildDir(), "classes/" + groovySourceSet.getTemplateDirSet().getName() + "/" + sourceSet.getName()));
// we do not support different versions of java from gradle right now...
// compile.getJavaLauncher().convention(getToolchainTool(project, JavaToolchainService::launcherFor));
});
JvmPluginsHelper.configureOutputDirectoryForSourceSet(sourceSet, groovySource, this.project, compileTask, compileTask.map(TemplateCompile::getOptions));
this.jvmPluginServices.useDefaultTargetPlatformInference(this.project.getConfigurations().getByName(sourceSet.getCompileClasspathConfigurationName()), compileTask);
this.jvmPluginServices.useDefaultTargetPlatformInference(this.project.getConfigurations().getByName(sourceSet.getRuntimeClasspathConfigurationName()), compileTask);
this.project.getTasks().named(sourceSet.getClassesTaskName(), (task) -> {
task.dependsOn(new Object[] { compileTask });
});
// Ties resources to be done first or something but we don't need this
// this.project.getConfigurations().getByName(sourceSet.getCompileClasspathConfigurationName()).attributes((attrs) -> {
// attrs.attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, (LibraryElements)this.project.getObjects().named(LibraryElements.class, "classes+resources"));
// });
});
// this.project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new ConfigureAction(this.project, objectFactory));
}
Aggregations