Skip to content

Commit

Permalink
More cleanups, including workspace cleanup lol
Browse files Browse the repository at this point in the history
  • Loading branch information
cybik committed Aug 28, 2016
1 parent 94c9c8a commit 0dc479b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 15 deletions.
7 changes: 6 additions & 1 deletion yafot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,22 @@ jar {
'Class-Path': configurations.runtime.files.collect {"$it.name"}.join(' ')
}
}

shadowJar {
configurations = [project.configurations.compile]
}

dependencies {
compile project(':googlejobb')

// Command line option parser
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"


}
4 changes: 2 additions & 2 deletions yafot/src/main/java/com/cybikbase/yafot/Assemblage.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public Assemblage(List<File> 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.

Expand All @@ -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<File, File> currentTuple = null;
for(File f: archList) {
Expand Down
48 changes: 36 additions & 12 deletions yafot/src/main/java/com/cybikbase/yafot/Yafot.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Void> halp = opt.acceptsAll(asList("h", "?", "usage", "help"), "Show this help").forHelp();
Expand All @@ -45,7 +46,6 @@ public void run(String[] args) {
.defaultsTo(1)
.required()
;

OptionSpec<String> password =
opt.acceptsAll(asList("k", "key"), "Key [password] to lock the file with. Optional.")
.withRequiredArg()
Expand All @@ -63,35 +63,39 @@ public void run(String[] args) {
.defaultsTo(new File("output"))
.required()
;

OptionSpec<File> 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,...")
.withValuesSeparatedBy(",")
;
OptionSpec<File> 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<File> 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<File> 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) {
Expand All @@ -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<Assemblage> 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.");
Expand All @@ -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();
}
Expand Down

0 comments on commit 0dc479b

Please sign in to comment.