Copying resources to JBoss with Maven

In my project, we use Maven to compile, build, package and deploy our application to JBoss 4.3. Every works fine. But each time a new developer comes along, or when we need to install a new server, we always have to remember to deploy the datasource and copy the MySQL JDBC Driver to JBoss. Nothing too complicated, but we tend to forget it. The file myproject-ds.xml defining the datasource needs to be copied to JBOSS_HOME/server/default/deploy and the mysql-connector-java-5.1.6.jar file needs to be copied to JBOSS_HOME/server/default/lib. To do that, we had an Ant script but people didn’t like the idea of using both Maven and Ant. So, why not using Maven profiles and the maven-resources-plugin to copy these two files to JBoss. The idea is to use an Initprofile to initialize JBoss (by typing mvn -PInit install). This will copy the files only once to JBoss. Then, the maven-resources-plugin can be used to copy the myproject-ds.xml (which is under the src\main\resources directory) and the MySQL driver (located in the local repository). So, with a bit of Maven knowledge, a little help from my friend Arnaud and a lot of trying, here is what I came with : Make sure you have the JBOSS_HOME variable set as this script uses env.JBOSS_HOME. The ${settings.localRepository} points to your local Maven repository. When I look at these 52 lines of XML that copy two files in two seperate directories, I either think that I’ve missed […]

Read More →