[CSS 2006] Using Maven 2 to get control over your Development Process
This afternoon I attended Hermod Opstvedt's talk on Using Maven 2 to get control over your Development Process. Most of it was review for me, but I took some notes anyway. About halfway through, I quit taking notes and just listened. The most interesting part for me was seeing how the Maven Embedder works. Since Maven doesn't currently allow you to create archetypes from existing projects the embedder seems like a good workaround. I'd rather code in Java rather than XML any day.
Near the end, Hermod tried to show us how you can easily create an Ant-based Mojo (Maven plugin), but his demo bombed thanks to an invalid pom in one of the plugin snapshots. Made Maven look pretty bad IMO - but snapshots always mess things up. ;-) The room was packed. Here's my notes:
It's a kind of project management tool. It focuses on standards and best practices, uses convention over configuration, shared language for build management, repeatable robust builds and acts as a central point in the Project Object Model (POM).
Maven History
Maven is a result of trying to make several Apache Software Foundation (ASF) project work in the same predictable way. Offshoot of the Turbine project and started by Jason van Zyl.
Objectives
Creates a common and understandable build infrastructure. If you know Maven, moving from one project to the next means you can focus on the problem at hand and not spend time trying to figure out the build system.
Common problems in a project: Traditionally, the larger the project, the more complex and build system becomes. Very often the build system is copied form a previous project that the senior developers participate in. Setting up an initial project through copy and past obviously can lead to interesting issues. Versioning of a project often becomes a nightmare if a strict regime of code management is not introduced. Documentation process is often "put off until later". Testing infrastructure is generally mediocre at best.
Maven solves these problems by introducing common build logic and uses a standard naming convention. There is also a single output from a single Maven project (often a contentious issue).
The Maven standard build lifecycle provides a lifecycle to hook into to perform custom logic with plugins.
Archetypes
What is an archetype? It's a template of a project which is combined with some user input to produce a working Maven project that has been tailored to your requirements. It's used to initialize a new project of a particular kind. To use the archetype plugin, it's as simple as running:
mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-webapp -DarchetypeArtifactId=maven-archetype-webappFor more information, see Maven's Guide to Webapps. Archetypes are very dumb for the most part - they're just a flat directory structure with files in it. However, if you want to create complex archetypes that execute something, it can't be done using the regular way. The solution is:
- Start out by creating an archetype for your standard structure
- Then in the pom for the project, add an <scm> section that will point to where your code is stored.
- Run "mvn archetype:create".
- Change to the root of your newly created project and run "mvn scm:update".
Posted by Mick Huisking on October 24, 2006 at 10:54 PM MDT #
Posted by 198.45.18.28 on October 25, 2006 at 01:48 PM MDT #