Skip to content

Commit

Permalink
avoid setting a release at compile time
Browse files Browse the repository at this point in the history
  • Loading branch information
carterkozak committed Oct 29, 2021
1 parent c7fce7d commit 721458f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public void execute(JavaCompile javaCompile) {
javaCompile.getJavaCompiler().set(javaToolchainService.compilerFor(new Action<JavaToolchainSpec>() {
@Override
public void execute(JavaToolchainSpec javaToolchainSpec) {
javaCompile.getOptions().getRelease().set((Integer) null);
javaToolchainSpec.getLanguageVersion().set(targetVersionProvider);
}
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import org.gradle.api.java.archives.Manifest;
import org.gradle.api.tasks.JavaExec;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.compile.JavaCompile;
import org.gradle.api.tasks.testing.Test;
import org.gradle.jvm.tasks.Jar;
import org.gradle.process.CommandLineArgumentProvider;
Expand All @@ -54,21 +56,21 @@ public void apply(Project project) {
project.getPluginManager().withPlugin("java", unused -> {
BaselineExportsExtension extension =
project.getExtensions().create(EXTENSION_NAME, BaselineExportsExtension.class, project);
// project.getExtensions().getByType(SourceSetContainer.class).configureEach(sourceSet -> {
// project.getTasks()
// .named(sourceSet.getCompileJavaTaskName(), JavaCompile.class)
// .get()
// .getOptions()
// .getCompilerArgumentProviders()
// // Use an anonymous class because tasks with lambda inputs cannot be cached
// .add(new CommandLineArgumentProvider() {
// @Override
// public Iterable<String> asArguments() {
// // Annotation processors are executed at compile time
// return collectAnnotationProcessorExports(project, extension, sourceSet);
// }
// });
// });
project.getExtensions().getByType(SourceSetContainer.class).configureEach(sourceSet -> {
project.getTasks()
.named(sourceSet.getCompileJavaTaskName(), JavaCompile.class)
.get()
.getOptions()
.getCompilerArgumentProviders()
// Use an anonymous class because tasks with lambda inputs cannot be cached
.add(new CommandLineArgumentProvider() {
@Override
public Iterable<String> asArguments() {
// Annotation processors are executed at compile time
return collectAnnotationProcessorExports(project, extension, sourceSet);
}
});
});

project.getTasks().withType(Test.class, new Action<Test>() {

Expand Down

0 comments on commit 721458f

Please sign in to comment.