Merge branch '2.5.x'

Closes gh-27307
pull/30691/head
Andy Wilkinson 3 years ago
commit 9ccd6a6f2f

@ -17,6 +17,7 @@
package org.springframework.boot.build.toolchain;
import org.gradle.api.Project;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.provider.Property;
import org.gradle.jvm.toolchain.JavaLanguageVersion;
@ -29,10 +30,13 @@ public class ToolchainExtension {
private final Property<JavaLanguageVersion> maximumCompatibleJavaVersion;
private final ListProperty<String> testJvmArgs;
private final JavaLanguageVersion javaVersion;
public ToolchainExtension(Project project) {
this.maximumCompatibleJavaVersion = project.getObjects().property(JavaLanguageVersion.class);
this.testJvmArgs = project.getObjects().listProperty(String.class);
String toolchainVersion = (String) project.findProperty("toolchainVersion");
this.javaVersion = (toolchainVersion != null) ? JavaLanguageVersion.of(toolchainVersion) : null;
}
@ -41,6 +45,10 @@ public class ToolchainExtension {
return this.maximumCompatibleJavaVersion;
}
public ListProperty<String> getTestJvmArgs() {
return this.testJvmArgs;
}
JavaLanguageVersion getJavaVersion() {
return this.javaVersion;
}

@ -17,7 +17,6 @@
package org.springframework.boot.build.toolchain;
import java.util.Collections;
import java.util.List;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
@ -56,7 +55,7 @@ public class ToolchainPlugin implements Plugin<Project> {
JavaToolchainSpec toolchainSpec = project.getExtensions().getByType(JavaPluginExtension.class)
.getToolchain();
toolchainSpec.getLanguageVersion().set(toolchain.getJavaVersion());
configureTestToolchain(project);
configureTestToolchain(project, toolchain);
}
}
@ -71,11 +70,9 @@ public class ToolchainPlugin implements Plugin<Project> {
project.getTasks().withType(Test.class, (task) -> task.setEnabled(false));
}
private void configureTestToolchain(Project project) {
project.getTasks().withType(Test.class, (test) -> {
List<String> arguments = Collections.singletonList("--illegal-access=warn");
test.jvmArgs(arguments);
});
private void configureTestToolchain(Project project, ToolchainExtension toolchain) {
project.getTasks().withType(Test.class,
(test) -> test.jvmArgs(toolchain.getTestJvmArgs().getOrElse(Collections.emptyList())));
}
}

@ -150,3 +150,7 @@ compileTestKotlin {
compileJava {
doLast new org.springframework.boot.build.log4j2.ReproducibleLog4j2PluginsDatAction()
}
toolchain {
testJvmArgs.add("--add-opens=java.base/java.net=ALL-UNNAMED")
}

Loading…
Cancel
Save