use of org.gradle.jvm.toolchain.JavaToolchainService in project spring-boot by spring-projects.
the class JavaPluginAction method configureToolchainConvention.
private void configureToolchainConvention(Project project, BootRun run) {
JavaToolchainSpec toolchain = project.getExtensions().getByType(JavaPluginExtension.class).getToolchain();
JavaToolchainService toolchainService = project.getExtensions().getByType(JavaToolchainService.class);
run.getJavaLauncher().convention(toolchainService.launcherFor(toolchain));
}
use of org.gradle.jvm.toolchain.JavaToolchainService in project gradle by gradle.
the class ScalaBasePlugin 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 gradle by gradle.
the class GroovyBasePlugin method configureSourceSetDefaults.
@SuppressWarnings("deprecation")
private void configureSourceSetDefaults() {
javaPluginExtension().getSourceSets().all(sourceSet -> {
final DefaultGroovySourceSet groovySourceSet = new DefaultGroovySourceSet("groovy", ((DefaultSourceSet) sourceSet).getDisplayName(), objectFactory);
addSourceSetExtension(sourceSet, groovySourceSet);
final SourceDirectorySet groovySource = groovySourceSet.getGroovy();
groovySource.srcDir("src/" + sourceSet.getName() + "/groovy");
// Explicitly capture only a FileCollection in the lambda below for compatibility with configuration-cache.
@SuppressWarnings("UnnecessaryLocalVariable") final FileCollection groovySourceFiles = groovySource;
sourceSet.getResources().getFilter().exclude(spec(element -> groovySourceFiles.contains(element.getFile())));
sourceSet.getAllJava().source(groovySource);
sourceSet.getAllSource().source(groovySource);
final TaskProvider<GroovyCompile> compileTask = project.getTasks().register(sourceSet.getCompileTaskName("groovy"), GroovyCompile.class, compile -> {
JvmPluginsHelper.configureForSourceSet(sourceSet, groovySource, compile, compile.getOptions(), project);
compile.setDescription("Compiles the " + sourceSet.getName() + " Groovy source.");
compile.setSource(groovySource);
compile.getJavaLauncher().convention(getToolchainTool(project, JavaToolchainService::launcherFor));
compile.getGroovyOptions().getDisabledGlobalASTTransformations().convention(Sets.newHashSet("groovy.grape.GrabAnnotationTransformation"));
});
String compileClasspathConfigurationName = sourceSet.getCompileClasspathConfigurationName();
JvmPluginsHelper.configureOutputDirectoryForSourceSet(sourceSet, groovySource, project, compileTask, compileTask.map(GroovyCompile::getOptions));
useDefaultTargetPlatformInference(compileTask, compileClasspathConfigurationName);
useDefaultTargetPlatformInference(compileTask, sourceSet.getRuntimeClasspathConfigurationName());
// TODO: `classes` should be a little more tied to the classesDirs for a SourceSet so every plugin
// doesn't need to do this.
project.getTasks().named(sourceSet.getClassesTaskName(), task -> task.dependsOn(compileTask));
// Explain that Groovy, for compile, also needs the resources (#9872)
project.getConfigurations().getByName(compileClasspathConfigurationName).attributes(attrs -> attrs.attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.getObjects().named(LibraryElements.class, LibraryElements.CLASSES_AND_RESOURCES)));
});
}
use of org.gradle.jvm.toolchain.JavaToolchainService in project gradle by gradle.
the class JavaBasePlugin method getToolchainTool.
private <T> Provider<T> getToolchainTool(Project project, BiFunction<JavaToolchainService, JavaToolchainSpec, Provider<T>> toolMapper) {
final JavaPluginExtension extension = project.getExtensions().getByType(JavaPluginExtension.class);
final JavaToolchainService service = project.getExtensions().getByType(JavaToolchainService.class);
return toolMapper.apply(service, extension.getToolchain());
}
use of org.gradle.jvm.toolchain.JavaToolchainService in project gradle by gradle.
the class ApplicationPlugin method getToolchainTool.
private <T> Provider<T> getToolchainTool(Project project, BiFunction<JavaToolchainService, JavaToolchainSpec, Provider<T>> toolMapper) {
final JavaPluginExtension extension = project.getExtensions().getByType(JavaPluginExtension.class);
final JavaToolchainService service = project.getExtensions().getByType(JavaToolchainService.class);
return toolMapper.apply(service, extension.getToolchain());
}
Aggregations