This is post describing how maven works. The example pom.xml is from Apache Mahout project at http://mahout.apache.org
- General description
Maven is a system for building a project.
- It manages the dependency of the projects. It can grab dependencies from a central repository, called maven central. In addition, it is also possible to install a local repository for local dependencies (possibly jars).
- It automatically sets up the lay out of the folders. In fact, the project directory can be created with commands. The layout of the project directory consists of src, target and a few folders.
- The various aspects of a maven project can be set through a pom.xml file.
- Build Sequence
- The default Maven build consists of several stages executed in a linear order (LIFECYCLE). A lot of the operations are declared during a specific stage. The default sequence is the following
To prevent generated sources from being generated, first in the LIFECYCLE, we can see that
|generate-sources||generate any source code for inclusion in compilation.|
So it is generated before compile. So I changed the <phase> tag from “generate-sources” to “install”. And instead of using “mvn clean –SkipTests install” command, I use “mvn compile” for two reasons
- Clean will remove all source files, forcing mahout math source files to be generated again
- Compile will only execute default LIFECYCLE up to the stage of “compile” and will not proceed to “install” stage.
Original tags inside trunk/math/pom.xml
- groupId seems to be related to the namespace of the library???
- Artifact Id is the name of the jar file without version and .jar extenstion. For example, for hadoop-core-1.0.3.jar artifactId is hadoop-core
- Version is the number after artifact Id, in the example of hadoop, it seems to be 1.0.3
- Scope is well introduced in the web page “Introduction to maven dependencies”
- Info about the entire project
- A pom file can indicate a parent
- Build Phases and goals
The build process is made up of several phases. Within each phase, there are finer grained tasks called goals.
<Generate> is a goal. <Execution> tag allows you to run the same goal multiple times with different configuration if needed.