There is too much controversy of moving from Ant to Maven, but maybe people don’t know that ant build scripts can be used with maven.
These are the step by step instructions:
- Create a minimal project.xml, that we’ll call POM (Project Object Model) or project descriptor. The most tedious task will be adding the dependencies needed to compile your classes, but you can use this search tool to get groupId and artifactId for them. If any of that dependencies are not at ibiblio repository copy the url of the repo, you’ll need it later. Change sourceDirectory to suit your needs.
3 yourgroup yourjar hibernate hibernate 2.1.6 springframework spring-core 1.1 src/java - Create a file maven.xml. This is the place to write ant scripts. You just have to rename targets to goals. You can get the current dir using ${basedir}.
<?xml version="1.0" encoding="ISO-8859-1"?> <project xmlns:j="jelly:core" xmlns:ant="jelly:ant" xmlns:maven="jelly:maven" xmlns:util="jelly:util"> <goal name="doSomething"> <!-- do some stuff using ant scripts --> <delete dir="${basedir}/adir"/> <mkdir dir="${basedir}/adir" /> <copy todir="${basedir}/adir"> <fileset dir="${basedir}/anotherdir"/> </copy> </goal> </project> - If you use some dependency not at ibiblio create a
project.propertiesfile with a linemaven.repo.remote=http://www.ibiblio.org/maven,http://cvs.apache.org/repositorywhere http://cvs.apache.org/repository is the url you copied early. You can add as much urls as you want, separated by commas. - Now you can run
maven doSomethingto execute the ant goal, and you can also callmaven java:compileto compile the classes,maven siteto generate a good looking website,… - A common complain of Ant users is speed. You can call
maven doSomething java:compileto run both goals or usemaven console, where ypu can type any goal without the startup penalty time. - Now you should be ready to check maven reference docs to explore the lots of features that maven can offer.
To sum up you can do with Maven everything you can do with Ant and many more things, so why don’t give it a try?