The Maven JBoss plugin can be used to perform some common tasks like deploy/undeploy or add resources as part of your Maven goal. This tutorial shows how to do it.
The Maven JBoss plugin, known as jboss-as-maven-plugin can be used to perform automatically some activities by connecting to a JBoss AS 7 running instance via the management port of the application server. If you don't provide any configuration detail about your server, the plugin will attemp connecting to the server located on localhost at port 9999.
So here's a minimal jboss-as-maven-plugin which can be added to your pom.xml file:
With this file in place, you can deploy your Maven application by executing simply:
The application can be also redeployed using the
In order to undeploy issue the following command:
If your server is not running on the default address/port, you can use the following configuration parameters in order to connect to it:
The configuration stanza can be used also to specify domain deployment. In this case, we are deploying our application to the other-server-group:
How to deploy an application to multiple servers ?
Using the configuration parameters it's possible to parametrize the plugin and then publish the application to a different set of servers:
Then pass the host and port to the maven shell:
How to add JBoss AS 7 dependencies to your artifacts ?
As you probably know, with JBoss AS 7 you need to explicitily declare your dependencies (except for core libraries) using the Dependencies element in the MANIFEST.MF file. For example:
Dependencies: org.infinispan export
You can achieve the same thing using the Maven plugins adding some configuration parameters. For a Web application:
And for an EJB application: