Build Automation #10 - Mavenizing your project - part 4
Maven handles transitive dependency through the POM of the dependent artifact. If you go to the ibiblio directory of Hibernate 3, http://www.ibiblio.org/maven2/org/hibernate/hibernate/3.1.3/ you can see that there is a hibernate-3.1.3.pom. Click on that and you can see the POM for the Hibernate artifact. You can clearly see all the artifacts that Hibernate is dependent upon from the dependencies section. So once you include Hibernate as a dependency to your project, Maven also gets all the necessary dependencies of Hibernate as well. It simplifies your job, and all you need to tell Maven is what are the artifacts your project is dependent upon.
We saw two important areas of Maven, POM and the repository where artifacts are stored in the remote as well as where Maven caches it locally (your user directory). There is a third important aspect of Maven, the plugins. In fact the artifact repository and the POM is put to use only with the help of plugins. You can relate the work of a plugin to that of a target in Ant. So are plugins special programs in Maven. Not really, they are also artifacts that reside in the ibiblio maven repository. The ant task equivalent in maven is a goal.
OK at this point if you want to test out the commands and samples that will come up, you need to download and install Maven2. To execute maven you need to specify at least one goal. For example to celan the previous build output directories, issue the following command.
c:/>mvn clean:clean
The first clean is the plugin name and the second clean is the goal name. Clean is a basic build lifecycle goal and hence the plugin prefix is optional. Meaning the following command has the same effect as the above.
c:/>mvn clean
The list of basic build lifecycle goals can be found here. A plugin is like any other artifact except that apart from a POM it also has an XML file called plugin.xml. The plugin.xml file contains all the goals that the plugin can perform. Open the maven-clean-plugin-2.1.jar in Winzip, extract and view the plugin.xml and study it. If you want to know more about creating plugins you can go through it here.










