Merge pull request #16248 from hengyunabc
* gh-16248: Polish "Prefer file: to jar:file: URLs in launcher" Prefer file: to jar:file: URLs in launcher Closes gh-16248
This commit is contained in:
commit
01abaa70f7
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2017 the original author or authors.
|
* Copyright 2012-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2018 the original author or authors.
|
* Copyright 2012-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -53,7 +53,7 @@ public class JarFileArchive implements Archive {
|
||||||
private File tempUnpackFolder;
|
private File tempUnpackFolder;
|
||||||
|
|
||||||
public JarFileArchive(File file) throws IOException {
|
public JarFileArchive(File file) throws IOException {
|
||||||
this(file, null);
|
this(file, file.toURI().toURL());
|
||||||
}
|
}
|
||||||
|
|
||||||
public JarFileArchive(File file, URL url) throws IOException {
|
public JarFileArchive(File file, URL url) throws IOException {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2017 the original author or authors.
|
* Copyright 2012-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -44,9 +44,7 @@ public class JarLauncherTests extends AbstractExecutableArchiveLauncherTests {
|
||||||
assertThat(archives).hasSize(2);
|
assertThat(archives).hasSize(2);
|
||||||
assertThat(getUrls(archives)).containsOnly(
|
assertThat(getUrls(archives)).containsOnly(
|
||||||
new File(explodedRoot, "BOOT-INF/classes").toURI().toURL(),
|
new File(explodedRoot, "BOOT-INF/classes").toURI().toURL(),
|
||||||
new URL("jar:"
|
new File(explodedRoot, "BOOT-INF/lib/foo.jar").toURI().toURL());
|
||||||
+ new File(explodedRoot, "BOOT-INF/lib/foo.jar").toURI().toURL()
|
|
||||||
+ "!/"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2018 the original author or authors.
|
* Copyright 2012-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -142,7 +142,7 @@ public class PropertiesLauncherTests {
|
||||||
assertThat(ReflectionTestUtils.getField(launcher, "paths").toString())
|
assertThat(ReflectionTestUtils.getField(launcher, "paths").toString())
|
||||||
.isEqualTo("[jars/]");
|
.isEqualTo("[jars/]");
|
||||||
List<Archive> archives = launcher.getClassPathArchives();
|
List<Archive> archives = launcher.getClassPathArchives();
|
||||||
assertThat(archives).areExactly(1, endingWith("app.jar!/"));
|
assertThat(archives).areExactly(1, endingWith("app.jar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -176,7 +176,7 @@ public class PropertiesLauncherTests {
|
||||||
.isEqualTo("[jar:file:./src/test/resources/nested-jars/app.jar!/]");
|
.isEqualTo("[jar:file:./src/test/resources/nested-jars/app.jar!/]");
|
||||||
List<Archive> archives = launcher.getClassPathArchives();
|
List<Archive> archives = launcher.getClassPathArchives();
|
||||||
assertThat(archives).areExactly(1, endingWith("foo.jar!/"));
|
assertThat(archives).areExactly(1, endingWith("foo.jar!/"));
|
||||||
assertThat(archives).areExactly(1, endingWith("app.jar!/"));
|
assertThat(archives).areExactly(1, endingWith("app.jar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -185,7 +185,7 @@ public class PropertiesLauncherTests {
|
||||||
PropertiesLauncher launcher = new PropertiesLauncher();
|
PropertiesLauncher launcher = new PropertiesLauncher();
|
||||||
List<Archive> archives = launcher.getClassPathArchives();
|
List<Archive> archives = launcher.getClassPathArchives();
|
||||||
assertThat(archives).areExactly(1, endingWith("foo.jar!/"));
|
assertThat(archives).areExactly(1, endingWith("foo.jar!/"));
|
||||||
assertThat(archives).areExactly(1, endingWith("app.jar!/"));
|
assertThat(archives).areExactly(1, endingWith("app.jar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -204,7 +204,7 @@ public class PropertiesLauncherTests {
|
||||||
PropertiesLauncher launcher = new PropertiesLauncher();
|
PropertiesLauncher launcher = new PropertiesLauncher();
|
||||||
List<Archive> archives = launcher.getClassPathArchives();
|
List<Archive> archives = launcher.getClassPathArchives();
|
||||||
assertThat(archives).areExactly(1, endingWith("foo.jar!/"));
|
assertThat(archives).areExactly(1, endingWith("foo.jar!/"));
|
||||||
assertThat(archives).areExactly(1, endingWith("app.jar!/"));
|
assertThat(archives).areExactly(1, endingWith("app.jar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2017 the original author or authors.
|
* Copyright 2012-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -44,9 +44,7 @@ public class WarLauncherTests extends AbstractExecutableArchiveLauncherTests {
|
||||||
assertThat(archives).hasSize(2);
|
assertThat(archives).hasSize(2);
|
||||||
assertThat(getUrls(archives)).containsOnly(
|
assertThat(getUrls(archives)).containsOnly(
|
||||||
new File(explodedRoot, "WEB-INF/classes").toURI().toURL(),
|
new File(explodedRoot, "WEB-INF/classes").toURI().toURL(),
|
||||||
new URL("jar:"
|
new File(explodedRoot, "WEB-INF/lib/foo.jar").toURI().toURL());
|
||||||
+ new File(explodedRoot, "WEB-INF/lib/foo.jar").toURI().toURL()
|
|
||||||
+ "!/"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -127,7 +127,7 @@ public class ExplodedArchiveTests {
|
||||||
Entry entry = getEntriesMap(this.archive).get("nested.jar");
|
Entry entry = getEntriesMap(this.archive).get("nested.jar");
|
||||||
Archive nested = this.archive.getNestedArchive(entry);
|
Archive nested = this.archive.getNestedArchive(entry);
|
||||||
assertThat(nested.getUrl().toString())
|
assertThat(nested.getUrl().toString())
|
||||||
.isEqualTo("jar:" + this.rootFolder.toURI() + "nested.jar!/");
|
.isEqualTo(this.rootFolder.toURI() + "nested.jar");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2018 the original author or authors.
|
* Copyright 2012-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -84,7 +84,7 @@ public class JarFileArchiveTests {
|
||||||
@Test
|
@Test
|
||||||
public void getUrl() throws Exception {
|
public void getUrl() throws Exception {
|
||||||
URL url = this.archive.getUrl();
|
URL url = this.archive.getUrl();
|
||||||
assertThat(url.toString()).isEqualTo("jar:" + this.rootJarFileUrl + "!/");
|
assertThat(url.toString()).isEqualTo(this.rootJarFileUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue