diff options
author | Shawn O. Pearce <sop@google.com> | 2009-06-12 11:48:31 -0700 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2009-06-12 11:48:31 -0700 |
commit | 9c9f8ba67d3fa08a519d0af495d54ad38ce285a6 (patch) | |
tree | 8bd28b848228016efddb87f88943a73d526d926f | |
parent | 4bca2c4d02556f3e44ffe957cf2efea756a3a99d (diff) | |
download | executablewar-master.tar.gz |
By setting -DExecutable-War-Package=blah on the JVM arguments we can
support launching code from the ExecutableWarMain without unpacking
it from the WAR file to local disk. This is handy if you are trying
to run the code through an IDE debugger.
Signed-off-by: Shawn O. Pearce <sop@google.com>
-rw-r--r-- | pom.xml | 2 | ||||
-rw-r--r-- | src/main/java/ExecutableWarMain.java | 26 |
2 files changed, 18 insertions, 10 deletions
@@ -21,7 +21,7 @@ limitations under the License. <groupId>gerrit</groupId> <artifactId>executablewar</artifactId> <packaging>jar</packaging> - <version>1.1</version> + <version>1.2</version> <name>executablewar</name> <description>Support for running code directly from WAR files</description> <url>http://android.git.kernel.org/?p=tools/executablewar.git</url> diff --git a/src/main/java/ExecutableWarMain.java b/src/main/java/ExecutableWarMain.java index 4d2e8fb..c93be7e 100644 --- a/src/main/java/ExecutableWarMain.java +++ b/src/main/java/ExecutableWarMain.java @@ -127,14 +127,7 @@ public class ExecutableWarMain { final String[] argv = new String[origArgv.length - 1]; System.arraycopy(origArgv, 1, argv, 0, argv.length); - final Attributes att = myManifest(); - String pkg = att.getValue(EXECUTABLE_WAR_PACKAGE); - if (pkg == null) { - pkg = ""; - } else { - pkg = pkg + "."; - } - + String pkg = cmdPackage(); Class<?> clazz; try { try { @@ -180,6 +173,21 @@ public class ExecutableWarMain { } } + private static String cmdPackage() throws IOException, MalformedURLException { + String pkg = System.getProperty(EXECUTABLE_WAR_PACKAGE); + if (pkg != null && !pkg.equals("")) { + return pkg + "."; + } + + pkg = myManifest().getValue(EXECUTABLE_WAR_PACKAGE); + if (pkg == null) { + pkg = ""; + } else { + pkg = pkg + "."; + } + return pkg; + } + private static Attributes myManifest() throws IOException, MalformedURLException { final InputStream mfin = @@ -237,7 +245,7 @@ public class ExecutableWarMain { throw new LinkageError("Cannot unpack libs from " + myURL); } if (paths.isEmpty()) { - throw new LinkageError("No files under WEB-INF/lib/"); + return ExecutableWarMain.class.getClassLoader(); } return new URLClassLoader(paths.toArray(new URL[paths.size()])); } |