Wednesday, August 26, 2009

Using Maven2 Cargo Plugin

I was trying to get Maven2 Cargo plugin to work for my proof of concept on parent-child multi module maven project. Since most practical real world maven projects will be such combination of both parent-child and multi module.

Following instructions on Cargo site works only if are executing your mvn cargo:* mojos from within the project directory that is cargo enabled (deployable). It does not work if you run it from parent project directory. I had tried running it from the parent project directory and the packaging type being "pom" ofcourse. You will get the following error

Maven LifecycleException ... The plugin 'org.apache.maven.plugins:maven-cargo-plugin' does not exist...

The error is really misleading because it tries to look for maven-cargo-plugin which is not what you included as a plugin groupId:artifactId:version for either pluginDepenency (in parent) or in your plugins section. You will really have to dig through a few posts before you can get some hints on how to fix it.

Now the fix part. There are 2 ways to fix this problem

1. Just cd into the project directory which needs to deploy the artifact to the app server and run mvn cargo:deploy
2. If you are like me, and would like to run this thing from CI engine (hudson), you would need to attach cargo:deploy to one of the existing maven phases e.g. install.

Thanks to concise and right on the money post for the clue.