Posts tagged ‘Ant Maven’

Maven : Accumulator of Knowledge – To Build a Project

Maven, a Yiddish word meaning accumulator of knowledge, was originally started as an attempt to simplify the build processes in the Jakarta Turbine project. There were several projects each with their own Ant build files that were all slightly different and JARs were checked into CVS. There’s came a need for a standard way to build the projects, a clear definition of what the project consisted of, an easy way to publish project information and a way to share JARs across several projects.

The result was a tool that can now be used for building and managing any Java-based project. It can create something that will make the day-to-day work of Java developers easier and generally help with the comprehension of any Java-based project.

Maven’s Objectives

Maven’s primary goal is to allow a developer to comprehend the complete state of a development effort in the shortest period of time. In order to attain this goal there are several areas of concern that Maven attempts to deal with:

• Making the build process easy
• Providing a uniform build system
• Providing quality project information
• Providing guidelines for best practices development
• Allowing transparent migration to new features

Feature Summary

The following are the key features of Maven in a nutshell:

• Simple project setup that follows best practices – get a new project or module started in seconds
• Consistent usage across all projects means no ramp up time for new developers coming onto a project
• Superior dependency management including automatic updating, dependency closures (also known as transitive dependencies)
• Able to easily work with multiple projects at the same time
• A large and growing repository of libraries and metadata to use out of the box, and arrangements in place with the largest Open Source projects for real-time availability of their latest releases
• Extensible, with the ability to easily write plugins in Java or scripting languages
• Instant access to new features with little or no extra configuration
• Ant tasks for dependency management and deployment outside of Maven
• Model based builds: Maven is able to build any number of projects into predefined output types such as a JAR, WAR, or distribution based on metadata about the project, without the need to do any scripting in most cases.
• Coherent site of project information: Using the same metadata as for the build process, Maven is able to generate a web site or PDF including any documentation you care to add, and adds to that standard reports about the state of development of the project. Examples of this information can be seen at the bottom of the left-hand navigation of this site under the “Project Information” and “Project Reports” submenus.
• Release management and distribution publication: Without much additional configuration, Maven will integrate with your source control system such as CVS and manage the release of a project based on a certain tag. It can also publish this to a distribution location for use by other projects. Maven is able to publish individual outputs such as a JAR, an archive including other dependencies and documentation, or as a source distribution.
• Dependency management: Maven encourages the use of a central repository of JARs and other dependencies. Maven comes with a mechanism that your project’s clients can use to download any JARs required for building your project from a central JAR repository much like Perl’s CPAN. This allows users of Maven to reuse JARs across projects and encourages communication between projects to ensure that backward compatibility issues are dealt with. We are collaborating with the folks at Ibiblio who have graciously allowed the central repository to live on their servers.

Working with Maven

Maven is a Java tool, so you must have Java installed in order to proceed.

First, download Maven and follow the installation instructions. After that, type the following in a terminal or in a command prompt:

mvn –version

It should print out your installed version of Maven, for example:

Maven version: 2.0.8
Java version: 1.5.0_12
OS name: “windows 2003” version: “5.2” arch: “x86” Family: “windows”

Depending upon your network setup, you may require extra configuration. Check out the Guide to Configuring Maven if necessary.

Download Maven:
Installation Instructions:
Guide to Configure Maven:

Creating a Project

On your command line, execute the following Maven goal:

mvn archetype:create -DartifactId=my-app

If you have just installed Maven, it may take a while on the first run. This is because Maven is downloading the most recent artifacts (plugin jars and other files) into your local repository. You may also need to execute the command a couple of times before it succeeds. This is because the remote server may time out before your downloads are complete. Don’t worry; there are ways to fix that.

You will notice that the create goal created a directory with the same name given as the artifactId. Change into that directory.

cd my-app

Under this directory you will notice the following standard project structure.

|– pom.xml
`– src
|– main
| `– java
| `– com
| `– mycompany
| `– app
| `–
`– test
`– java
`– com
`– mycompany
`– app

The src/main/java directory contains the project source code, the src/test/java directory contains the test source, and the pom.xml is the project’s Project Object Model, or POM.


The pom.xml file is the core of a project’s configuration in Maven. It is a single configuration file that contains the majority of information required to build a project in just the way you want. The POM is huge and can be daunting in its complexity, but it is not necessary to understand all of the intricacies just yet to use it effectively. This project’s POM is:

<project xmlns="" xmlns:xsi=""
  <name>Maven Quick Start Archetype</name>

August 4, 2008 at 11:16 am 3 comments

Important Notice

I have moved to my new website..


Blog Stats

  • 24,704 visitors have read this blog.


Indi BLogger’s Rank


Recent Posts

Top Clicks

  • None

My Tweets