Maven 2.x Exec Plugin

Goal to execute a class in an arbitrary artifact outside of any specific project

Details

  • Type: New Feature New Feature
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: java
  • Labels:
    None
  • Number of attachments :
    0

Description

The idea is to have a goal as part of 'exec" plugin for running Java "main" classes similar to exec:java goal but w/o requiring a project (i.e. @requiredProject = false). I.e. a goal that could run a main class in an arbitrary artifact.

For instance, one could run Xalan's XSLT command line (http://xml.apache.org/xalan-j/commandline.html) like this:

java -classpath ... org.apache.xalan.xslt.Process -IN foo.xml -XSL foo.xsl -OUT foo.out

Instead, the new goal would allow to run:

mvn exec:java-ext -Dartifact=xalan:xalan:2.7.1 -DmainClass=org.apache.xalan.xslt.Process "-Dargs=-IN foo.xml -XSL foo.xsl -OUT foo.out"

When this command is executed, the Maven will download and install Xalan from central repository along with all its dependencies, build a separate classloader using artifact/dependency information, find the class (Process) and execute it's main method passing in the specified arguments. All these steps will be done automatically by Maven and thus will take any issues from a user that would otherwise be required (downloading binary distribution and all dependencies, building classpath, etc). Essentially this would create a "zero" footprint model for executing an arbitrary java main-class - all that is necessary here is Maven itself.

The benefits of this model should be attractive. Besides simplifying download/install/execute process, this is also a good code distribution model: one could create a library, deploy it to enterprise-wide Maven repository and execute it on any number of hosts via SSH w/o any additional actions.

P.S. This model is fairly simple and extensible. All of the Maven pieces are already there and used successfully in this plugin and many others. The closest example to this would be Groovy's Grape. The same execution there could look like:

groovy.grape.Grape.grab(group:'xalan', module:'xalan', version:'2.7.1')
org.apache.xalan.xslt.Process.main("-IN", "foo.xml", "-XSL", "foo.xsl", "-OUT", "foo.out")

Thus, again the idea seems straightforward and implementation should be fairly simple as well. If you think this idea has legs I can volunteer to provide the implementation code.

Activity

There are no comments yet on this issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: