Maven is the Apache build manager for Java projects
Maven is a software project management tool, based on project object model. It aims at reducing the load of developer by making in software build process simple and faster.
Following are worth mentioning features of Maven:
- Provides a uniform build system
- Provides quality project information
- Provides guidelines for best practices development
- Allows transparent migration to new features
When to use Maven is an interesting question.
Maven uses an XML project descriptor to generate the object model for project. This file is POM.XML and should be located at the top level directory of the project.
The XML file contains all the needed information for the project. Apart from core information, it also contains groupid, version, name and all the libraries needed for the project.
A project object model (POM.xml) contains all necessary information about a project like configurations of plugins involved. You might be thinking about Ant build file. You may embed ant tasks inside the POM. A build.xml tells Ant precisely what to do when it is run, a POM states its configuration.
A POM in simplest form is given below:
You want Maven to compile your unit tests. Simply place you unit tests in a directory and mention the director under
Once that is done, specify the unit tests which you want to run in unitTest XML element. You may use includes and excludes tags to include or exclude the classes. Java Code: **/*Test*.java
Everyone know how important it is to document the project. I wont be shedding light on this. But the aim of this post is
to introduce how Maven can help you generate project documentation.
Maven can actually generate a website for your project. Use following command to generate documentation:
Run the site:generate goal for your project with this command:
Maven will generate html documentation in the docs
Maven can manage all jar file dependencies for the build machines. Let me explain how to do this.
We use dependency element to refer to a jar file which reside in a remote repository. It is said that in near future, the dependencies will extend beyond jar files. Maven places the jar files (fetched from remote repository) on the local repository. The element has three child elements, , , and . Maven looks in the remote repository for a directory with the same name as
Maven can be integrated in to Eclipse my using M2Eclipse (Tycho). Is is true to say that it is the most mature of the Eclipse integration projects.
Worth mentioning features of M2Eclipse include:
- Launching Maven builds from within Eclipse
- Dependency management for Eclipse build path based on Maven's pom.xml
- Resolving Maven dependencies from the Eclipse workspace without installing to local Maven repository
- Automatic downloading of the required
In Maven, projects can share dependencies which means that different project can use common jar files.
These jar files will be updated over time and Maven keeps each project current with the latest jar file. These jar files will be placed in a repository on a remote server and are accessed by the projects. These files will be mirrored in a local repository under the Maven installation. The remote repository location is given in the driver.properties file which is located in your Maven