diff --git a/yafot/build.gradle b/yafot/build.gradle index 31038ed..13c367b 100644 --- a/yafot/build.gradle +++ b/yafot/build.gradle @@ -18,9 +18,11 @@ jar { 'Class-Path': configurations.runtime.files.collect {"$it.name"}.join(' ') } } + shadowJar { configurations = [project.configurations.compile] } + dependencies { compile project(':googlejobb') @@ -28,7 +30,10 @@ dependencies { compile "net.sf.jopt-simple:jopt-simple:5.0.2" // Tuples - //compile "com.github.martinstuga:tuples4j:1.2" compile "org.javatuples:javatuples:1.2" + // Files. Eugh, commons + compile "commons-io:commons-io:2.5" + + } \ No newline at end of file diff --git a/yafot/src/main/java/com/cybikbase/yafot/Assemblage.java b/yafot/src/main/java/com/cybikbase/yafot/Assemblage.java index ec3863f..7000f37 100644 --- a/yafot/src/main/java/com/cybikbase/yafot/Assemblage.java +++ b/yafot/src/main/java/com/cybikbase/yafot/Assemblage.java @@ -29,7 +29,7 @@ public Assemblage(List vs, File v, boolean isPatch) { } - public Assemblage run() { + public Assemblage run(File inputTempDir) { // Stage 2: List either archives or input directory. Sidenote: if we're getting a GFS list, we move all of // them to a default temp dir and use THAT dir for our obb base. @@ -53,7 +53,7 @@ public Assemblage run() { } else if(!inputDirExistence && archListExistence) { undoArchiveAssemblage = true; oldAndNewTuples = new ArrayList<>(); - inputDirValue = new File("yafot-temp-dir/archives-"+(isPatchFile?"patch":"main")); + inputDirValue = new File(inputTempDir.getAbsolutePath()+File.separator+"archives-"+(isPatchFile?"patch":"main")); inputDirValue.mkdirs(); Pair currentTuple = null; for(File f: archList) { diff --git a/yafot/src/main/java/com/cybikbase/yafot/Yafot.java b/yafot/src/main/java/com/cybikbase/yafot/Yafot.java index 91e198c..160b5db 100644 --- a/yafot/src/main/java/com/cybikbase/yafot/Yafot.java +++ b/yafot/src/main/java/com/cybikbase/yafot/Yafot.java @@ -9,6 +9,7 @@ import joptsimple.OptionParser; import joptsimple.OptionSet; import joptsimple.OptionSpec; +import org.apache.commons.io.FileUtils; import static java.lang.System.exit; import static java.util.Arrays.asList; @@ -25,7 +26,7 @@ public void run(String[] args) { OptionParser opt = new OptionParser() { { // Pre-done because there's kind of a circular dep in here. - acceptsAll(asList("a", "artifacts", "i", "input-dir")); + acceptsAll(asList("a","artifacts","i","input-dir","b","artifacts-patch","j","input-dir-patch")); } }; OptionSpec halp = opt.acceptsAll(asList("h", "?", "usage", "help"), "Show this help").forHelp(); @@ -45,7 +46,6 @@ public void run(String[] args) { .defaultsTo(1) .required() ; - OptionSpec password = opt.acceptsAll(asList("k", "key"), "Key [password] to lock the file with. Optional.") .withRequiredArg() @@ -63,9 +63,10 @@ public void run(String[] args) { .defaultsTo(new File("output")) .required() ; + OptionSpec artifacts = opt.acceptsAll(asList("a", "artifacts"), "Artifacts to pack - per file.") - .requiredUnless("i", "input-dir") + .availableUnless("i", "input-dir") .withRequiredArg() .ofType(File.class) .describedAs("art1,art2,...") @@ -73,25 +74,28 @@ public void run(String[] args) { ; OptionSpec artifactsPatch = opt.acceptsAll(asList("b", "artifacts-patch"), "Artifacts to pack in the patch obb - per file.") + .availableUnless("j", "input-dir-patch") .withOptionalArg() .ofType(File.class) .describedAs("artp1,artp2,...") .withValuesSeparatedBy(",") ; + OptionSpec inputDir = opt.acceptsAll(asList("i", "input-dir"), "Artifacts to pack - per dir.") - .requiredUnless("a", "artifacts") + .availableUnless("a", "artifacts") .withRequiredArg() .ofType(File.class) .describedAs("dir") ; OptionSpec inputDirPatch = - opt.acceptsAll( - asList("j", "input-dir-patch"), "Artifacts to pack in patch obb - per dir.") + opt.acceptsAll(asList("j", "input-dir-patch"), "Artifacts to pack in patch obb - per dir.") + .availableUnless("b", "artifacts-patch") .withOptionalArg() .ofType(File.class) .describedAs("dir") ; + try { opt.printHelpOn(System.out); } catch (IOException e) { @@ -112,16 +116,19 @@ public void run(String[] args) { if(!outputDirValue.mkdirs()) throw new RuntimeException("Creating outputdir failed"); } + File inputTempDir = new File("yafot-temp-dir"); + inputTempDir.mkdirs(); + // Stage 2: List either archives or input directory. Sidenote: if we're getting a GFS list, we move all of // them to a default temp dir and use THAT dir for our obb base. List allAssemblages = new ArrayList<>(); // Main assemblage. - allAssemblages.add((new Assemblage(opts.valuesOf(artifacts), opts.valueOf(inputDir))).run()); + allAssemblages.add((new Assemblage(opts.valuesOf(artifacts), opts.valueOf(inputDir))).run(inputTempDir)); if(Assemblage.isThereAPatch(opts.valuesOf(artifactsPatch), opts.valueOf(inputDirPatch))) { allAssemblages.add( - (new Assemblage(opts.valuesOf(artifactsPatch), opts.valueOf(inputDirPatch), true)).run() + (new Assemblage(opts.valuesOf(artifactsPatch), opts.valueOf(inputDirPatch), true)).run(inputTempDir) ); } else { System.out.println("No patchfile generation required."); @@ -139,18 +146,35 @@ public void run(String[] args) { String.valueOf(opts.valueOf(version)), // package version opts.valueOf(password) // password characters ); - System.out.println("The OBB assemblage is being called using these arguments."); - for(String s: arguments) System.out.println(s); + System.out.print("The OBB assemblage is being called using these arguments."); + for(String s: arguments) { + if(s.startsWith("-")){ + System.out.println(); + System.out.print('\t'); + } + else System.out.print(" "); + System.out.print(s); + } + System.out.println(); System.out.println("Note that some of these are forced defaults, as the creator of YAFOT is using YAFOT in that way."); // Call obb NAO invoke(arguments, - new File("yafot/output-obb"+(assemblageSet.isPatchFile?"-patch":"")+".log"), - new File("yafot/output-obb-err"+(assemblageSet.isPatchFile?"-patch":"")+".log") + new File("yafot/output"+(assemblageSet.isPatchFile?"-patch":"")+"-obb.log"), + new File("yafot/output"+(assemblageSet.isPatchFile?"-patch":"")+"-obb-err.log") ); assemblageSet.unrun(); } + if(inputTempDir != null && inputTempDir.exists()) { + System.out.println("WHY WON'T THIS DELETE " + inputTempDir.getAbsolutePath()); + try { + FileUtils.forceDeleteOnExit(inputTempDir); + } catch (IOException e) { + throw new RuntimeException("Couldn't even force delete, what?"); + } + } + } else { (new YafotUI(this)).execute(); }