Using WSO2 CAR Deploy Plug-In
The WSO2 CAR Deploy plug-in for Maven allows you to generate a Composite Application aRchive (CAR) file for a Composite Application (C-App) project and then deploy it (or undeploy it) to multiple local and remote Carbon servers, including StratosLivePaas. You can also deploy an existing CAR file by specifying its location.
To use this plug-in to generate and deploy a new CAR file, add it to the pom.xml
 file of your C-App project and then use the mvn clean deploy
 command to generate and deploy the CAR. To use this plug-in to deploy an existing CAR file, add it to any pom.xml
 file, specify the location of the CAR file in the
<archiveLocation>
 element, and then use the mvn clean deploy
 command to deploy the CAR.Â
See the Deploying a CAR File with the Maven Plug-In sample for a walk-though of how to deploy a CAR file containing ESB artifacts.
Adding the plug-in to the POM file
<plugin> <groupId>org.wso2.maven</groupId> <artifactId>maven-car-deploy-plugin</artifactId> <version>1.0.0</version> <extensions>true</extensions> <configuration> <carbonServers> <CarbonServer> <trustStorePath>${basedir}/src/main/resources/security/wso2carbon.jks </trustStorePath> <trustStorePassword>wso2carbon</trustStorePassword> <trustStoreType>JKS</trustStoreType> <serverUrl>https://${host}:${port}</serverUrl> <userName>admin</userName> <password>${password}</password> <operation>deploy|undeploy</operation> </CarbonServer> <CarbonServer> <trustStorePath>${basedir}/src/main/resources/security/wso2carbon.jks </trustStorePath> <trustStorePassword>wso2carbon</trustStorePassword> <trustStoreType>JKS</trustStoreType> <serverUrl>https://localhost:9445</serverUrl> <userName>admin</userName> <password>admin</password> <operation>deploy|undeploy</operation> </CarbonServer> . . . </carbonServers> <archiveLocation>/mylocation/mycar_1.0.0.car</archiveLocation> </configuration> </plugin>
- Under the C-App project that you want to deploy, double-click theÂ
pom.xml
 file to open it in the editor. - Click the Source tab and navigate to theÂ
maven-car-deploy-plugin
 underÂ<build>
 ->Â<plugins>
. - Modify theÂ
maven-car-deploy-plugin
 properties as follows:- UnderÂ
<carbonServers>
, create oneÂ<CarbonServer>
 for each Carbon server where you want to deploy the CAR file. - Specify the following properties for each Carbon server:
- If you are using a custom certificate with your Carbon server, import the public key of the custom certificate to your trust store, and then set theÂ
<trustStorePath>
,Â<trustStorePassword>
, andÂ<trustStoreType>
 properties to the location, password, and type of your trust store. - Set theÂ
<serverUrl>
,Â<userName>
, andÂ<password>
 properties to the URL (such as https://localhost:9443
), user name, and password for the Carbon server. - In theÂ
<operation>
 element, specify whether to deploy or undeploy the CAR file for this Carbon server.To deploy:Â
<operation>deploy</operation>
To undeploy:Â
<operation>undeploy</operation>
 - If you want to deploy an existing CAR file, specify the path to that CAR file in theÂ
<archiveLocation>
 element. A dd the following line to the properties to ensure that the CAR file will be deployed:
<maven.car.deploy.skip>false</maven.car.deploy.skip>
If you want to deploy the CAR file to a remote Maven repository in addition to the Carbon servers, add the following line to the properties:
<maven.deploy.skip>false</maven.deploy.skip>Â
You will be able to override both of these settings when you run the Maven command. - If you are using a custom certificate with your Carbon server, import the public key of the custom certificate to your trust store, and then set theÂ
- UnderÂ
- Save the file. You are now ready to generate and deploy the CAR file for this C-App.
Generating and deploying the CAR file
You now run the mvn clean deploy
 command to generate the CAR file and deploy it to the Carbon servers in a single step. You can add parameters to the command to override the configuration. For example, to deploy the CAR file to the Carbon servers but not to the remote Maven repository, add the -Dmaven.deploy.skip=true
 parameter, as follows:
mvn clean deploy -Dmaven.deploy.skip=true
If you want to deploy to the remote Maven repository but not the Carbon servers, add the -Dmaven.car.deploy.skip=true
 parameter, as follows:
mvn clean deploy -Dmaven.car.deploy.skip=true
You can also skip deployment to both the remote repository AND the Carbon servers:
mvn clean deploy -Dmaven.deploy.skip=true -Dmaven.car.deploy.skip=true
Some useful Maven commands
The following are some useful Maven commands for a selective deployment of a CAR file to a remote Maven repository (Nexus) as well as to Carbon servers:
Skip deployment of CAR file to remote Maven repository and continue the deployment of CAR file to given Carbon server(s):
mvn clean deploy -Dmaven.deploy.skip=true -Dmaven.car.deploy.skip=false
Skip deployment of CAR file to given Carbon server(s) and continue the deployment of CAR file to a remote Maven repository:
mvn clean deploy -Dmaven.deploy.skip=false -Dmaven.car.deploy.skip=true
Deploy the CAR file to both Carbon server(s) as well as to a remote Maven repository:
mvn clean deploy -Dmaven.deploy.skip=false -Dmaven.car.deploy.skip=false
It is also possible to declare theÂ
<maven.car.deploy.skip>
 property in the properties section of the pom.xml and provide a parameter from the command line. In that case, the property value declared in the pom.xml will get overridden by the parameter value provided in the command line.In order to enable the deployment of a CAR file to Carbon server, you can also addÂ
<maven.car.deploy.skip>false</maven.car.deploy.skip>
 to the properties section of the C-App project pom.xml
Using these commands and aforementioned properties, you can do a selective deployment of a CAR file to a remote Maven repository as well as to Carbon servers.