in JOnAS, Maven

Start/stop Jonas with Maven and Cargo. And deploy too.

I found very little information on what to add exactly to the POM.xml file to start/stop Jonas with Maven and Cargo.
So here is a quick example with a basic webapp application.

1) Create a webapp maven project :

mvn archetype:generate  -DgroupId=com.company.celinio  -DartifactId=celinio  -DpackageName=com.company.celinio.examples -Dversion=1.0-SNAPSHOT

Choose the archetype 104 (maven-archetype-webapp):

The directory structure is the following :

2) Install the web application with the following command :

mvn install

The WAR archive is then copied to the repository :

The WAR archive is previously generated under the target folder :

2) Edit the POM.xml file to add the following profile :

<profiles>

<profile>						
<id>cargo</id>						
<activation>	
<activeByDefault>true</activeByDefault>					
</activation>						
<build>						
<plugins>						
<plugin>						
<groupId>org.codehaus.cargo</groupId>						
<artifactId>cargo-maven2-plugin</artifactId>						
<version>1.0.6</version>						
<executions>						
<execution>						
	<id>start-jonas</id>						
	<phase>pre-integration-test</phase>						
	<goals>						
	<goal>start</goal>						
	</goals>						
</execution>						
<execution>						
	<id>stop-jonas</id>						
	<phase>post-integration-test</phase>						
	<goals>						
	<goal>stop</goal>						
	</goals>						
</execution>						
</executions>						
<configuration>						
<container>						
<containerId>jonas5x</containerId>						
<type>installed</type>						
<home>D:\Dev\jonas-full-5.1.6\</home>						
</container>						
<configuration>						
	<type>existing</type>						
	<home>D:\Dev\jonas-full-5.1.6\</home>						
	<properties>						
			<cargo.servlet.port>9000</cargo.servlet.port>						
			<cargo.hostname>localhost</cargo.hostname>						
			<cargo.protocol>http</cargo.protocol>						
			<cargo.jonas.server.name>jonas</cargo.jonas.server.name>						
			<cargo.jonas.domain.name>jonas</cargo.jonas.domain.name>						
	</properties>						
</configuration>						
<deployer>						
<deployables>						
		<deployable>						
			<groupId>${project.groupId}</groupId>						
			<artifactId>${project.artifactId}</artifactId>						
			<type>${project.packaging}</type>						
			<classifier>${config.classifier}</classifier>						
		</deployable>						
</deployables>						
</deployer>						
</configuration>						
</plugin>						
</plugins>						
</build>						
</profile>
</profiles>

The profile cargo is the default active profile :

<activeByDefault>true</activeByDefault>

3) Deploy the WAR archive to Jonas (folder deploy) with the following command :

mvn cargo:deploy

4) Finally start the server :

mvn cargo:start


5) Test the webapp :

6) Stop the server with the following command :

mvn cargo:stop

Link :
http://cargo.codehaus.org/Maven2+plugin