Maven cargo:deploy

Update: added Pom file configuration section

Keith helped me get the Maven cargo deploy set up for me today, so instead of having to manually copy the .war file over to JBoss’s server\default\deploy directory after running the “Maven Clean Install” external tool I have set up, I can just run a Maven Deploy to Local JBoss, which will build the .war file and deploy it.

The changes I had to make were minimal:

Changes to settings.xml

In C:\Documents and Settings\myusername\.m2 I edited the settings.xml file to add the following:


Eclipse External Tool configuration

The other component is the Eclipse External Tool configuration.

Name: Maven Deploy to Local JBoss
Location: ${env_var:M2_HOME}\bin\mvn.bat (you could just hardcode the path, but one benefit abstracting it buys us is the ability to share the resulting configuration file among developers)
Working Directory: ${project_loc}
Arguments: clean install cargo:deploy

Pom file configuration

The third part of the setup is to add the following to your project’s pom.xml file, as a child element of the <project> element:


(Those variables, such as ${jbossPath}, are magic to me — I don’t remember defining them, but it’s possible my Eclipse setup came with them already defined.)


Of course, the immediate benefit of having this working Deploy external tool configuration is that when I want to build and deploy it’s now a one-step operation instead of two.  There’s a bigger benefit though:

When all day I’m making changes and deploying, I will often do something else while the .war file is being built.  It’s often a few minutes before I get back to copy the file over to JBoss, and by that time, I may not remember if I’ve made any more code changes since I last built.  So I re-run the install operation, this time waiting for it to complete (maybe).  There are probably many times that I rebuild when the .war already had the latest code changes, and that’s a waste of time and energy.  Having this tool available will eliminate that waste.


7 thoughts on “Maven cargo:deploy

  1. Thanks for this – helped me immensely.

    FYI – the ‘magic’ properties are simply taken from the settings.xml:

    becomes ${jbossPath}


  2. I’m glad it helped you! And thanks for explaining the magic… now I see the profiles -> profile -> properties -> jbossPath setting.

  3. What if I want to have the generated maven warfile deployed on a remote host? Here is the scenario:

    On server “A” have a perl/bash script checkout latest SVN version of a project, have maven build it and using the maven-cargodeploy place the generated war on server “B” then possibly bounce the server.

  4. Hi
    Good one, Thanks~! I am having a problem in that the war is getting deployed to the existing tomcat but without the name as “.war”. Very Strange, but I have set the name, finalName for the build etc etc without any success. Any ideas?

  5. Vidhya,

    Is it deploying successfully? If so, I wonder if it matters that the .war extension is missing.

    Beyond that, I am not in an enterprise Java environment right now to be familiar with this issue, but you might try the Cargo mailing lists.

    God bless,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.