Last modified: Mar 20, 2014
Another Apache project, Maven came well after Ant had come to dominate the Java open source landscape.
Initially seen as a competitor or replacement for Ant
Motivations for Maven
Grew out of an observation that many supposedly cooperative, related Apache projects had inconsistent and incompatible ant build structures.
Stated goals are
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
Uniform Build System
Archetypes can be obtained from the Maven project or tailored for an organization.
Providing quality project information
Provides easy access to report tools
Aids in building & maintaining project web sites (e.g.)
Providing guidelines for best practices development
Directory structures (already discussed)
Unit testing
Encourage familiarity with approved archetypes
Perhaps the best way to illustrate this is to follow the steps in Maven in 5 Minutes
Start with the command
mvn archetype:generate -DgroupId=edu.odu.cs \ -DartifactId=codeAnnotation \ -DarchetypeArtifactId=maven-archetype-quickstart \ -DinteractiveMode=false
Building with the Sample Source
Run mvn package
Explore the target directory to see what has been placed there
OK, that was fun…
Let’s try this with some real source code.
Delete the target directory (or run mvn clean)
Try mvn package again.
What Went Wrong?
Edit the pom.xml file and, just above the <dependencies> section, add <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> </properties>
Then try mvn package again
That was a little better
The main source code compiled successfully.
The first error message says
[ERROR] /home/.../codeAnnotation/src/test/java/edu/odu/cs/codeAnnotation/TestC2HOptions.java:[3,23] package org.junit does not exist
Looks to be a problem with the JUnit library