Search code examples
javamavendeploymentaether

Automatically download and run standalone Java app from Maven


I would like to have an application/script that I could use to execute a stand alone Java application (i.e. a basic class with a main method) from a given Maven artifact. Based on my research nothing like this currently exists, but I thought I'd ask the question to the community and see if anyone knows of a project that could support my needs.

The idea would be that I would pass in, either via a config file or the command line, a Maven artifact spec (group ID, artifact ID, and version) along with a fully qualified class name and a list of arguments. The given artifact and all of its dependencies would then be downloaded (or not if they're already in the local repo) and the application would be launched with the appropriate classpath.

At this point I don't think it will be too difficult to implement a system that does this using the Aether library and Java's ProcessBuilder, but I was wondering if anyone else knew of an existing project that already handles this before I start reinventing the wheel.


Solution

  • Perhaps this is obvious, but why wont the exec plugin work? http://mojo.codehaus.org/exec-maven-plugin/

    mvn exec:java -Dexec.mainClass=com.project.App
    

    If com.project.App were part of another jar, you would include it as a dependency like you normally would.