Skip to content

Commit

Permalink
Polish "Allow additional JVM args when running tests via toolchain"
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed Jul 13, 2021
1 parent 01b0156 commit 705feee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -69,10 +71,8 @@ private void disableToolchainTasks(Project 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())));
}

}
8 changes: 4 additions & 4 deletions spring-boot-project/spring-boot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
}

0 comments on commit 705feee

Please sign in to comment.