Merge branch '1.3.x'
This commit is contained in:
commit
43d30cc5bc
|
|
@ -96,7 +96,7 @@ final class ChangeableUrls implements Iterable<URL> {
|
||||||
return Collections.<URL>emptyList();
|
return Collections.<URL>emptyList();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return getUrlsFromClassPathAttribute(jarFile.getManifest());
|
return getUrlsFromClassPathAttribute(url, jarFile.getManifest());
|
||||||
}
|
}
|
||||||
catch (IOException ex) {
|
catch (IOException ex) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
|
|
@ -117,7 +117,7 @@ final class ChangeableUrls implements Iterable<URL> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<URL> getUrlsFromClassPathAttribute(Manifest manifest) {
|
private static List<URL> getUrlsFromClassPathAttribute(URL base, Manifest manifest) {
|
||||||
String classPath = manifest.getMainAttributes()
|
String classPath = manifest.getMainAttributes()
|
||||||
.getValue(Attributes.Name.CLASS_PATH);
|
.getValue(Attributes.Name.CLASS_PATH);
|
||||||
if (!StringUtils.hasText(classPath)) {
|
if (!StringUtils.hasText(classPath)) {
|
||||||
|
|
@ -127,7 +127,7 @@ final class ChangeableUrls implements Iterable<URL> {
|
||||||
List<URL> urls = new ArrayList<URL>(entries.length);
|
List<URL> urls = new ArrayList<URL>(entries.length);
|
||||||
for (String entry : entries) {
|
for (String entry : entries) {
|
||||||
try {
|
try {
|
||||||
urls.add(new URL(entry));
|
urls.add(new URL(base, entry));
|
||||||
}
|
}
|
||||||
catch (MalformedURLException ex) {
|
catch (MalformedURLException ex) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
|
|
|
||||||
|
|
@ -75,10 +75,12 @@ public class ChangeableUrlsTests {
|
||||||
public void urlsFromJarClassPathAreConsidered() throws Exception {
|
public void urlsFromJarClassPathAreConsidered() throws Exception {
|
||||||
URL projectCore = makeUrl("project-core");
|
URL projectCore = makeUrl("project-core");
|
||||||
URL projectWeb = makeUrl("project-web");
|
URL projectWeb = makeUrl("project-web");
|
||||||
|
File relative = this.temporaryFolder.newFolder();
|
||||||
ChangeableUrls urls = ChangeableUrls.fromUrlClassLoader(new URLClassLoader(
|
ChangeableUrls urls = ChangeableUrls.fromUrlClassLoader(new URLClassLoader(
|
||||||
new URL[] { makeJarFileWithUrlsInManifestClassPath(projectCore,
|
new URL[] { makeJarFileWithUrlsInManifestClassPath(projectCore,
|
||||||
projectWeb) }));
|
projectWeb, relative.getName() + "/") }));
|
||||||
assertThat(urls.toList()).containsExactly(projectCore, projectWeb);
|
assertThat(urls.toList()).containsExactly(projectCore, projectWeb,
|
||||||
|
relative.toURI().toURL());
|
||||||
}
|
}
|
||||||
|
|
||||||
private URL makeUrl(String name) throws IOException {
|
private URL makeUrl(String name) throws IOException {
|
||||||
|
|
@ -90,7 +92,7 @@ public class ChangeableUrlsTests {
|
||||||
return file.toURI().toURL();
|
return file.toURI().toURL();
|
||||||
}
|
}
|
||||||
|
|
||||||
private URL makeJarFileWithUrlsInManifestClassPath(URL... urls) throws Exception {
|
private URL makeJarFileWithUrlsInManifestClassPath(Object... urls) throws Exception {
|
||||||
File classpathJar = this.temporaryFolder.newFile("classpath.jar");
|
File classpathJar = this.temporaryFolder.newFile("classpath.jar");
|
||||||
Manifest manifest = new Manifest();
|
Manifest manifest = new Manifest();
|
||||||
manifest.getMainAttributes().putValue(Attributes.Name.MANIFEST_VERSION.toString(),
|
manifest.getMainAttributes().putValue(Attributes.Name.MANIFEST_VERSION.toString(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue