Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
fbelzunc committed Jan 13, 2015
1 parent 2f59ffc commit 6351a8a
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions core/src/main/java/hudson/ClassicPluginStrategy.java
Expand Up @@ -56,6 +56,8 @@
import java.io.FilenameFilter;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -147,8 +149,8 @@ private static Manifest loadLinkedManifest(File archive) throws IOException {

@Override public PluginWrapper createPluginWrapper(File archive) throws IOException {
final Manifest manifest;
URL baseResourceURL;

URL baseResourceURL = null;
File expandDir = null;
// if .hpi, this is the directory where war is expanded

Expand Down Expand Up @@ -197,7 +199,21 @@ private static Manifest loadLinkedManifest(File archive) throws IOException {
if (libs != null)
paths.addAll(Arrays.asList(libs));

baseResourceURL = expandDir.toURI().toURL();
try {
Class pathJDK7 = Class.forName("java.nio.file.Path");
Object toPath = File.class.getMethod("toPath").invoke(expandDir);
URI uri = (URI) pathJDK7.getMethod("toUri").invoke(toPath);

baseResourceURL = uri.toURL();
} catch (NoSuchMethodException e) {
throw new Error(e);
} catch (ClassNotFoundException e) {
baseResourceURL = expandDir.toURI().toURL();
} catch (InvocationTargetException e) {
throw new Error(e);
} catch (IllegalAccessException e) {
throw new Error(e);
}
}
File disableFile = new File(archive.getPath() + ".disabled");
if (disableFile.exists()) {
Expand Down

0 comments on commit 6351a8a

Please sign in to comment.