Polish "Allow additional JVM args when running tests via toolchain"

See gh-27089
This commit is contained in:
Andy Wilkinson 2021-07-13 15:28:04 +01:00
parent 01b0156fed
commit 705feeed6a
2 changed files with 8 additions and 8 deletions

View File

@ -16,6 +16,8 @@
package org.springframework.boot.build.toolchain;
import java.util.Collections;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.plugins.JavaPluginExtension;
@ -69,10 +71,8 @@ public class ToolchainPlugin implements Plugin<Project> {
}
private void configureTestToolchain(Project project, ToolchainExtension toolchain) {
if (!toolchain.getTestJvmArgs().isPresent()) {
return;
}
project.getTasks().withType(Test.class, (test) -> test.jvmArgs(toolchain.getTestJvmArgs().get()));
project.getTasks().withType(Test.class,
(test) -> test.jvmArgs(toolchain.getTestJvmArgs().getOrElse(Collections.emptyList())));
}
}

View File

@ -9,10 +9,6 @@ plugins {
description = "Spring Boot"
toolchain {
testJvmArgs.add("--add-opens=java.base/java.net=ALL-UNNAMED")
}
def tomcatConfigProperties = "$buildDir/tomcat-config-properties"
configurations {
@ -154,3 +150,7 @@ compileTestKotlin {
compileJava {
doLast new org.springframework.boot.build.log4j2.ReproducibleLog4j2PluginsDatAction()
}
toolchain {
testJvmArgs.add("--add-opens=java.base/java.net=ALL-UNNAMED")
}