3

I have a .war file that represents a complex web application. It works that way perfectly. But one of the classes in WEB-INF/classes also has a main() that is a small helper utility. We'd like to be able to run that utility from the command line. It seems to me there ought to be a way to form a classpath out of all of the jars in WEB-INF/lib inside the war, plus WEB-INF/classes.

It just seems to me like this is a problem that has to have been solved before.

Worst case, I can unpack the war into a temp directory, but I'd really rather not.

nsayer
  • 16,925
  • 3
  • 33
  • 51
  • If you're using Maven, you can have the build process (with maven-jar-plugin) create a separate jar file containing only the utility class in addition to the full war file. – Kayaman Nov 20 '15 at 21:23
  • @azurefrog it does indeed look like a duplicate of that one. My search skills failed me first time. – nsayer Nov 20 '15 at 21:27
  • We are using maven, but it would be nicer to avoid a separate artifact. Whether that's more ugly than unpacking the war into a temp dir though... :) – nsayer Nov 20 '15 at 21:28
  • Isn't your application server unpacking the WAR File? Then you could run the class easily on the CLI. – burna Nov 20 '15 at 21:32
  • The utility needs to be able to be run before the application server is started the first time. – nsayer Nov 20 '15 at 23:11

0 Answers0