|
16 | 16 |
|
17 | 17 | package org.springframework.boot.build;
|
18 | 18 |
|
| 19 | +import java.io.File; |
| 20 | +import java.io.IOException; |
| 21 | +import java.io.InputStream; |
| 22 | +import java.nio.file.Files; |
| 23 | +import java.nio.file.Path; |
19 | 24 | import java.util.Arrays;
|
20 | 25 | import java.util.Collections;
|
21 | 26 | import java.util.List;
|
|
26 | 31 |
|
27 | 32 | import io.spring.javaformat.gradle.FormatTask;
|
28 | 33 | import io.spring.javaformat.gradle.SpringJavaFormatPlugin;
|
| 34 | +import org.gradle.api.Action; |
29 | 35 | import org.gradle.api.JavaVersion;
|
30 | 36 | import org.gradle.api.Project;
|
| 37 | +import org.gradle.api.Task; |
31 | 38 | import org.gradle.api.artifacts.Configuration;
|
32 | 39 | import org.gradle.api.artifacts.ConfigurationContainer;
|
33 | 40 | import org.gradle.api.artifacts.Dependency;
|
@@ -147,10 +154,14 @@ private void configureTestConventions(Project project) {
|
147 | 154 | project.getTasks().withType(Test.class, (test) -> {
|
148 | 155 | test.useJUnitPlatform();
|
149 | 156 | test.setMaxHeapSize("1024M");
|
| 157 | + CopyJdk8156584SecurityProperties copyJdk8156584SecurityProperties = new CopyJdk8156584SecurityProperties( |
| 158 | + project); |
150 | 159 | if (buildingWithJava8(project)) {
|
151 | 160 | test.systemProperty("java.security.properties",
|
152 |
| - getClass().getClassLoader().getResource("jdk-8156584-security.properties")); |
| 161 | + "file:" + test.getWorkingDir().toPath().relativize(copyJdk8156584SecurityProperties.output)); |
| 162 | + test.setDebug(true); |
153 | 163 | }
|
| 164 | + test.doFirst(copyJdk8156584SecurityProperties); |
154 | 165 | });
|
155 | 166 | project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> project.getDependencies()
|
156 | 167 | .add(JavaPlugin.TEST_RUNTIME_ONLY_CONFIGURATION_NAME, "org.junit.platform:junit-platform-launcher"));
|
@@ -226,4 +237,27 @@ private void configureToolchain(Project project) {
|
226 | 237 | project.getPlugins().apply(ToolchainPlugin.class);
|
227 | 238 | }
|
228 | 239 |
|
| 240 | + private static final class CopyJdk8156584SecurityProperties implements Action<Task> { |
| 241 | + |
| 242 | + private static final String SECURITY_PROPERTIES_FILE_NAME = "jdk-8156584-security.properties"; |
| 243 | + |
| 244 | + private final Path output; |
| 245 | + |
| 246 | + private CopyJdk8156584SecurityProperties(Project project) { |
| 247 | + this.output = new File(project.getBuildDir(), SECURITY_PROPERTIES_FILE_NAME).toPath(); |
| 248 | + } |
| 249 | + |
| 250 | + @Override |
| 251 | + public void execute(Task task) { |
| 252 | + try (InputStream input = getClass().getClassLoader() |
| 253 | + .getResourceAsStream(CopyJdk8156584SecurityProperties.SECURITY_PROPERTIES_FILE_NAME)) { |
| 254 | + Files.copy(input, this.output); |
| 255 | + } |
| 256 | + catch (IOException ex) { |
| 257 | + throw new RuntimeException(ex); |
| 258 | + } |
| 259 | + } |
| 260 | + |
| 261 | + } |
| 262 | + |
229 | 263 | }
|
0 commit comments