Archive for February, 2009

Maven Hello World

Tuesday, February 24th, 2009 | java | No Comments

I’ve been looking at Maven (2.0) recently as part of my work with the Digital Enterprise Research Institute (DERI) . In the past, most projects I’ve worked on used Apache Ant which works pretty well. Maven is a lot more complex than Ant (see some of its features in What is Maven?) but can be used as a “better Ant” if that’s all you need/want (and it seems like a sensible way to start moving to Maven).

Three things I like about Maven from the start:

  1. Maven includes support for managing dependencies allowing your project to automatically specify what 3rd party JARs it depends on and automatically downloading those at compile-time rather than requiring other developers to spend time hunting for these applications.
  2. Maven espouses the idea of convention over configuration for its configuration. This is great, in essence, Maven tries to provide sensible defaults as much as possible so you can use it with the minimum of configuration/effort. If you don’t like these conventions, you can change them, but for the casual user, the effort required to start using the tool is low. This is a great approach, all software should strive to be easy to start using (while catering for the power users by enabling the engine to be tweaked if you want to get your hands dirty under the hood).
  3. Related to the previous point, it’s remarkably easy to build a new Hello World application (a good smoke test for tools like this). Likemvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-webapp -DgroupId=ie.atlanticlinux -DartifactId=HelloWorld

    to create a new project and

    mvn package

    to build a test WAR file which you can just drop into your Tomcat webapps directory and immediately test.

Tags: , , , ,