diff options
author | Andy Clement <aclement@pivotal.io> | 2019-02-08 15:07:23 -0800 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2019-02-08 15:07:23 -0800 |
commit | ce1533d8493277d1111005e890f076ef90b32eab (patch) | |
tree | 33a21d3dae587a98245d784525d74a284b7dafab /build | |
parent | 635f0ed47ffe11e93d96e4d24e4411eedfa1ddc9 (diff) | |
download | aspectj-ce1533d8493277d1111005e890f076ef90b32eab.tar.gz aspectj-ce1533d8493277d1111005e890f076ef90b32eab.zip |
Fix getSpecFile() to work with URLs and adjust installer unpacker
Diffstat (limited to 'build')
-rw-r--r-- | build/src/main/java/$installer$/org/aspectj/Main.java | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/build/src/main/java/$installer$/org/aspectj/Main.java b/build/src/main/java/$installer$/org/aspectj/Main.java index 748b035ae..536c86293 100644 --- a/build/src/main/java/$installer$/org/aspectj/Main.java +++ b/build/src/main/java/$installer$/org/aspectj/Main.java @@ -39,9 +39,13 @@ import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintStream; import java.lang.reflect.InvocationTargetException; +import java.net.JarURLConnection; import java.net.URL; +import java.util.Enumeration; import java.util.Map; import java.util.Properties; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -1478,17 +1482,37 @@ class CurrentJarUnpacker { writeStream(getClass().getResourceAsStream("/" + name), outputFile); } + public void writeResource(JarFile jarFile, JarEntry entry, File outputDir) throws IOException { + String name = entry.getName().substring(6); + File outputFile = makeOutputFile(name, outputDir); + //System.out.println("finding name: " + name); +// writeStream(getClass().getResourceAsStream("/" + name), outputFile); + writeStream(jarFile.getInputStream(entry), outputFile); + } + public void unpack(String contentsName, File outputDir) throws IOException { URL url = getClass().getResource(contentsName); - InputStream stream = url.openStream(); - BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "US-ASCII")); - - String line = reader.readLine(); - installPane.nBytes = Integer.parseInt(line); - - while ((line = reader.readLine()) != null) { - writeResource(line, outputDir); + + // Process everything under 'files/**' copying to the target + // install directory with 'files/' removed + JarURLConnection juc = (JarURLConnection) url.openConnection(); + JarFile jf = juc.getJarFile(); + Enumeration<JarEntry> entries = jf.entries(); + while (entries.hasMoreElements()) { + JarEntry je = entries.nextElement(); + if (je.getName().startsWith("files/") && !je.getName().endsWith("/")) { + writeResource(jf, je, outputDir); + } } + +// InputStream stream = url.openStream(); +// BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "US-ASCII")); +// String line = reader.readLine(); +// installPane.nBytes = Integer.parseInt(line); +// +// while ((line = reader.readLine()) != null) { +// writeResource(line, outputDir); +// } installPane.progressMessage("done writing"); } |