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.


, ,

  1. #1 by Mike Burke on September 21, 2008 - 9:39 pm

    Thanks for this – helped me immensely.

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

    becomes ${jbossPath}


  2. #2 by Mike Burke on September 21, 2008 - 9:40 pm

    sorry, no preview:

    <jbossPath> becomes ${jbossPath}

  3. #3 by danielmeyer on September 22, 2008 - 7:30 am

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

  4. #4 by diego bowen on March 30, 2010 - 8:44 pm

    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.

  5. #5 by danielmeyer on March 31, 2010 - 2:01 am


    As I recall, you can deploy on a remote host (there’s an example here).

    It looks from a cursory glance that the maven cargo plugin does support stopping and stopping a container, but only a local one.

  6. #6 by Vidhya on July 15, 2010 - 11:10 am

    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?

  7. #7 by danielmeyer on July 15, 2010 - 4:30 pm


    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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s