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