Add support for remote --first-jar/--second-jar

Example:
java -jar target/SpecialSource-1.3-SNAPSHOT-shaded.jar --first-jar http://assets.minecraft.net/1_4_7/minecraft_server.jar --second-jar http://repo.bukkit.org/content/groups/public/org/bukkit/minecraft-server/1.4.7/minecraft-server-1.4.7.jar
This commit is contained in:
Agaricus 2013-02-28 20:18:11 -08:00
parent 308d1b4413
commit 91803d03ea
2 changed files with 6 additions and 6 deletions

View File

@ -51,11 +51,11 @@ public class SpecialSource {
acceptsAll(asList("a", "first-jar"), "First jar with original names, for generating mapping")
.withRequiredArg()
.ofType(File.class);
.ofType(String.class);
acceptsAll(asList("b", "second-jar"), "Second jar with renamed names, for generating mapping")
.withRequiredArg()
.ofType(File.class);
.ofType(String.class);
acceptsAll(asList("s", "srg-out"), "Mapping file output")
.withRequiredArg()
@ -127,8 +127,8 @@ public class SpecialSource {
if (options.has("first-jar") && options.has("second-jar")) {
// Generate mappings from two otherwise-identical jars
log("Reading jars");
Jar jar1 = Jar.init((File) options.valueOf("first-jar"));
Jar jar2 = Jar.init((File) options.valueOf("second-jar"));
Jar jar1 = Jar.init(URLDownloader.getLocalFile((String) options.valueOf("first-jar")));
Jar jar2 = Jar.init(URLDownloader.getLocalFile((String) options.valueOf("second-jar")));
log("Creating jar compare");
JarComparer visitor1 = new JarComparer(jar1);

View File

@ -48,14 +48,14 @@ public class URLDownloader {
System.out.println("Downloading "+url);
}
url.openConnection();
url.openConnection(); // TODO: cache local downloads, and reuse temp files unless forced
InputStream inputStream = url.openStream();
String path = url.getPath();
String baseName = URLDownloader.getNameWithoutExtension(path);
String extension = Files.getFileExtension(path);
File tempFile = File.createTempFile(baseName, "." + extension);
File tempFile = File.createTempFile(baseName, "." + extension); // TODO: use non-random filenames
FileOutputStream outputStream = new FileOutputStream(tempFile);
byte[] buffer = new byte[4096];