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 :
</project> ... <profiles> <profile> <id>Init</id> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.3</version> <executions> <execution> <phase>install</phase> <configuration> <tasks> <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" /> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles> </project>
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 !
Categories: Java
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
end
ET BIM!!!
The complete example with Gradle