Skip to content

Commit

Permalink
add -version_file option to AppLauncher #1158
Browse files Browse the repository at this point in the history
  • Loading branch information
rbouckaert committed Aug 5, 2024
1 parent d3d6a5c commit 5ab2236
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions src/beastfx/app/tools/AppLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ public void runAppFromCMD(PackageApp packageApp, String[] additionalArgs) {
BEASTClassLoader.classLoader.addJar(jarFile);
}
}


additionalArgs = processVersionFileArguments(additionalArgs);

Class<?> mainClass = BEASTClassLoader.forName(packageApp.className, "has.main.method");
Method mainMethod = mainClass.getMethod("main", String [].class);
System.err.println("About to invoke " + packageApp.className + " " + mainMethod);
Expand All @@ -321,6 +323,34 @@ public void runAppFromCMD(PackageApp packageApp, String[] additionalArgs) {

}

private String[] processVersionFileArguments(String[] additionalArgs) {
// process version file arguments;
boolean foundVersionFileArgument = false;
for (int i = 0; i < additionalArgs.length; i++) {
if (additionalArgs.equals("-version_file")) {
additionalArgs[i] = "";
i++;
while (i < additionalArgs.length && !additionalArgs[i].startsWith("-")) {
BEASTClassLoader.addServices(additionalArgs[i]);
additionalArgs[i] = "";
i++;
foundVersionFileArgument = true;
}
}
}
if (foundVersionFileArgument) {
List<String> args = new ArrayList<>();
for (String str : additionalArgs) {
if (!str.equals("")) {
args.add(str);
}
}
additionalArgs = args.toArray(new String[] {});
}
return additionalArgs;
}


private String sanitise(String property) {
// sanitise for windows
if (beastfx.app.util.Utils.isWindows()) {
Expand Down Expand Up @@ -405,7 +435,6 @@ public static void main(String[] args) {
appStore.printAppList(appStore.getPackageApps(), System.out);
}
System.exit(0);

default:
System.err.print("\nUnsupported option.");
appStore.printUsage(System.err);
Expand Down

0 comments on commit 5ab2236

Please sign in to comment.