Home
Maven Shell for Maven 3.0, 3.x
The Sonatype open source Maven Shell project supersedes the work of this project for Maven 3.0. This plugin remains useful for Maven 2.x, but with Maven 3.0 on the horizon, all efforts are being focused on the new Maven Shell project which has significantly more features than the Maven CLI Plugin. Check it and Maven 3 out today. They are a pair of awesome products.
Maven-3.0-Support
Maven 3.0 support is on the way, but needs volunteers to write a unit test around MojoExecutor and perhaps refactor it a bit. It was merely a coding-in-anger exercise that ended up spanning 15 hours of research, trial and error. Maven 3.0 is an exciting new version of the build tool we know and love, but as you can imagine, the documentation of how to convert things like plugins to this version are still in the incubation phase.
About The Plugin
The Maven CLI Plugin provides an interactive command line interface to Maven plugins, allowing you to execute specific plugin goals, phases, and alias common goal sets on a single project or set of sub-modules. The motivation for this plugin is to reduce the amount of time executing Maven tasks, specifically repeated tasks. The CLI supports command history via the “up” and “down” arrows and tab completion.
The Maven CLI Plugin can also install a special Intellij IDEA plugin to allow you to execute commands with a single keystroke without leaving your IDE.
See the User Guide for more information.
Downloads
You can download the jars, source, and javadocs from the Maven 2 repository:
bq. http://twdata-m2-repository.googlecode.com/svn/org/twdata/maven/maven-cli-plugin/
Difference between execute and execute-phase
Most developers that commonly invoke “mvn install” from the command line will be most at home with the “execute-phase” goal. It interprets your command line inputs and phases you wish to execute. As with the typical maven invocation, a phase will execute any prerequisite phases, so “install” at this goal’s prompt will also run compile, test, jar and package.
The “execute” goal on the other hand, is executing plugins, not phases. So, if you execute “install” from within a ready instance of the execute goal, you’ll find that it expects you to have run compile and jar on your own, manually, or else it will fail. Beneath the covers, “install” at the “execute” goal’s prompt is running “mvn org.apache.maven.plugins:maven-install-plugin:install”
Example Usage
The is the output from using the CLI “execute” goal:
mrdon@makoa:~/dev/maven-cli-plugin$ mvn cli:execute
[INFO] Scanning for projects...
WAGON_VERSION: 1.0-beta-2
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven CLI Plugin
[INFO] task-segment: [org.twdata.maven:maven-cli-plugin:execute]
[INFO] ------------------------------------------------------------------------
[INFO] [cli:execute]
[INFO] Waiting for commands
maven2> compile
[INFO] Executing: org.apache.maven.plugins:maven-compiler-plugin [compile]
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] Execution time: 255 ms
maven2> clean compile
[INFO] Executing: org.apache.maven.plugins:maven-clean-plugin [clean]
[INFO] [clean:clean]
[INFO] Deleting directory /home/mrdon/dev/maven-cli-plugin/target
[INFO] Execution time: 335 ms
[INFO] Executing: org.apache.maven.plugins:maven-compiler-plugin [compile]
[INFO] [compiler:compile {execution: virtual-execution}]
[INFO] Compiling 1 source file to /home/mrdon/dev/maven-cli-plugin/target/classes
[INFO] Execution time: 352 ms
maven2> exit
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 minutes
[INFO] Finished at: Sat Aug 02 21:44:09 GMT+10:00 2008
[INFO] Final Memory: 10M/135M
[INFO] ------------------------------------------------------------------------
mrdon@makoa:~/dev/maven-cli-plugin$
Maven Repository
Add this to your pom.xml:
<pluginRepositories>
<pluginRepository>
<id>twdata-m2-repository</id>
<name>twdata.org Maven 2 Repository</name>
<url>http://twdata-m2-repository.googlecode.com/svn/</url>
</pluginRepository>
</pluginRepositories>
