Merge branch '3.3.x' into 3.4.x
Closes gh-44364
This commit is contained in:
@@ -79,6 +79,11 @@ final class ClassPath {
|
|||||||
return this.path;
|
return this.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.path;
|
||||||
|
}
|
||||||
|
|
||||||
private Path createArgFile() throws IOException {
|
private Path createArgFile() throws IOException {
|
||||||
Path argFile = Files.createTempFile("spring-boot-", ".argfile");
|
Path argFile = Files.createTempFile("spring-boot-", ".argfile");
|
||||||
argFile.toFile().deleteOnExit();
|
argFile.toFile().deleteOnExit();
|
||||||
@@ -121,9 +126,8 @@ final class ClassPath {
|
|||||||
* @return a new {@link ClassPath} instance
|
* @return a new {@link ClassPath} instance
|
||||||
*/
|
*/
|
||||||
static ClassPath of(UnaryOperator<String> getSystemProperty, List<URL> urls) {
|
static ClassPath of(UnaryOperator<String> getSystemProperty, List<URL> urls) {
|
||||||
boolean preferrArgFile = urls.size() > 1 && isWindows(getSystemProperty);
|
boolean preferArgFile = urls.size() > 1 && isWindows(getSystemProperty);
|
||||||
return new ClassPath(preferrArgFile,
|
return new ClassPath(preferArgFile, urls.stream().map(ClassPath::toPathString).collect(JOIN_BY_PATH_SEPARATOR));
|
||||||
urls.stream().map(ClassPath::toPathString).collect(JOIN_BY_PATH_SEPARATOR));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isWindows(UnaryOperator<String> getSystemProperty) {
|
private static boolean isWindows(UnaryOperator<String> getSystemProperty) {
|
||||||
|
|||||||
@@ -85,6 +85,14 @@ class ClassPathTests {
|
|||||||
assertThat(classPath.args(true)).containsExactly("-cp", path1 + File.pathSeparator + path2);
|
assertThat(classPath.args(true)).containsExactly("-cp", path1 + File.pathSeparator + path2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void toStringShouldReturnClassPath(@TempDir Path temp) throws Exception {
|
||||||
|
Path path1 = temp.resolve("test1.jar");
|
||||||
|
Path path2 = temp.resolve("test2.jar");
|
||||||
|
ClassPath classPath = ClassPath.of(onLinux(), List.of(path1.toUri().toURL(), path2.toUri().toURL()));
|
||||||
|
assertThat(classPath.toString()).isEqualTo(path1 + File.pathSeparator + path2);
|
||||||
|
}
|
||||||
|
|
||||||
private UnaryOperator<String> onWindows() {
|
private UnaryOperator<String> onWindows() {
|
||||||
return Map.of("os.name", "windows")::get;
|
return Map.of("os.name", "windows")::get;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user