Copying resources to JBoss with Maven (and Antrun)

On my previous post I explained how painful it was to copy resources (files, librairies…) with Maven and the maven-resources-plugin. And guess what ? I received 2 emails from Maven lovers telling me that for this kind of task, Antrun would be more appropriate. So I thought I should give it a try to be fully honest with me, Maven, and God (you need a bit of faith when Maven is involved). So, keeping the same approach as explained on my previous post (use of a Maven profile, copying one datasource and one jar file…), here is what the pom.xml would look like with Antrun :

[sourcecode language=”xml”]


<copy file="src/main/resources/lwr-ds.xml"
todir="${env.JBOSS_HOME}/server/default/deploy" />
<copy file="${settings.localRepository}/mysql/mysql-connector-java/5.1.6/mysql-connector-java-5.1.6.jar"
todir="${env.JBOSS_HOME}/server/default/lib" />


Ok, it’s only 28 lines of XML. Compare with the 52 on the previous post, it’s a shorter pom.xml. But I still find that incredibly verbose just to copy two files.

If you are around next week in Paris, Zenika and Skills Matter are organising a presentation of Gradle by Hans Dockter. I’ll be there !

3 thoughts on “Copying resources to JBoss with Maven (and Antrun)

  1. With buildr:

    task ‘install’ => ‘jboss’ do
    cp _(‘src/main/resources/lwr-ds.xml’), JBOSS_HOME/server/default/lib
    cp repositories.locate(MYSQL), JBOSS_HOME/server/default/lib

  2. The complete example with Gradle

    usePlugin 'java'
    def env=System.getenv()
      description ='Container for dirver connector'
      transitive = false
     drivers "mysql:mysql-connector-java:3.0.10"
    libs < 
        ant.copy(file: file, todir: env['JBOSS_HOME']+"/server/default/lib")

Leave a Reply