We're updating the issue view to help you get more done. 

Cargo still deploys autodeployable even if <deployables> is not empty in a WAR project packaging



I have been trying to setup the Cargo Maven Plugin in our project which has the WAR packaging. In that project, we build a standalone microservice using Thorntail, hence the WAR packaging. This microservice is started using java -jar command by another Maven Plugin. The microservice then contacts other application in WildFly, which is downloaded, deployed, started and managed by Cargo.

The issue is that Cargo tries to deploy the microservice on WildFly as well because the project itself is a WAR packaging, but I only want it to deploy just that WildFly application.

I work with one of the contributors, Karel Suta, and we looked first at the documentation of cargo:start which says:

1 If the plugin configuration contains no deployables but the project's packaging is Java EE (WAR, EAR, etc.), it will deploy the project's deployable to to the container automatically.

So 2 conditions: no deployables defined AND Java EE packaging.

But as you can see, we have a deployable specified (WildFly app), but it still deploys the project's deployable.

In fact, when we looked at the code here and here and also at the JavaDoc of the addAutoDeployDeployable method, it says:

1 If the project's packaging is war, ear or ejb and there is no deployer specified and the user has not defined the auto-deployable inside the <deployables> element, then add the generated artifact to the list of deployables to deploy statically.

So the real conditions are:

  • Java EE packaging

  • No deployer specified by the user

  • Auto-deployable not specified in the deployables element

Which we satisfy, so from the code perspective it works.

The issue is that we have to work around it by setting <deployer/>, which will set it basically to non-null and condition in addAutoDeployDeployable method will not be satisfied.

We think that either the documentation on the website should be fixed, or, preferably, we should alter the code so it behaves like the documentation on the website. I think it can be easily fixed by removing

1 || !containsAutoDeployable(getDeployablesElement())

from the addAutoDeployDeployable method. So Cargo won't deploy the project's deployable if the deployables element has already something specified. Of course, if a user wanted to deploy that as well, they can always add such a deployment do deployables.

What do you think?





Marian Macik


Marian Macik


Fix versions

Affects versions