From 4fd707d54dcab200a68a65d4e81379992abec4db Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 10 Feb 2016 12:02:23 -0800 Subject: [PATCH] Added support for "class = manifest". This causes Getdown to run your app using java -jar code.jar instead of java -classpath code.jar classname. See wiki docs for more info. --- .../threerings/getdown/data/Application.java | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/threerings/getdown/data/Application.java b/src/main/java/com/threerings/getdown/data/Application.java index 02a164a..9ba5b35 100644 --- a/src/main/java/com/threerings/getdown/data/Application.java +++ b/src/main/java/com/threerings/getdown/data/Application.java @@ -57,6 +57,9 @@ public class Application /** Suffix used for control file signatures. */ public static final String SIGNATURE_SUFFIX = ".sig"; + /** A special classname that means 'use -jar code.jar' instead of a classname. */ + public static final String MANIFEST_CLASS = "manifest"; + /** Used to communicate information about the UI displayed when updating the application. */ public static class UpdateInterface { @@ -889,7 +892,15 @@ public class Application public Process createProcess (boolean optimum) throws IOException { - // create our classpath + ArrayList args = new ArrayList(); + + // reconstruct the path to the JVM + args.add(LaunchUtil.getJVMPath(_appdir, _windebug || optimum)); + + // check whether we're using -jar mode or -classpath mode + boolean dashJarMode = MANIFEST_CLASS.equals(_class); + + // add the -classpath arguments if we're not in -jar mode StringBuilder cpbuf = new StringBuilder(); for (Resource rsrc : getActiveCodeResources()) { if (cpbuf.length() > 0) { @@ -897,15 +908,10 @@ public class Application } cpbuf.append(rsrc.getFinalTarget().getAbsolutePath()); } - - ArrayList args = new ArrayList(); - - // reconstruct the path to the JVM - args.add(LaunchUtil.getJVMPath(_appdir, _windebug || optimum)); - - // add the classpath arguments - args.add("-classpath"); - args.add(cpbuf.toString()); + if (!dashJarMode) { + args.add("-classpath"); + args.add(cpbuf.toString()); + } // we love our Mac users, so we do nice things to preserve our application identity if (RunAnywhere.isMacOS()) { @@ -951,8 +957,13 @@ public class Application args.add(processArg(string)); } - // add the application class name - args.add(_class); + // if we're in -jar mode add those arguments, otherwise add the app class name + if (dashJarMode) { + args.add("-jar"); + args.add(cpbuf.toString()); + } else { + args.add(_class); + } // finally add the application arguments for (String string : _appargs) {