|
Maven is a popular build framework that is used by many technology professionals to manage large scale java application development. The Apache Maven website (http://maven.apache.org) states that "Maven is a software project management and comprehension tool". Maven builds are based upon a project object model (POM) which is coded in XML. Maven is used to manage a project's build, reporting and documentation from a central place. I have worked with both Maven 1.0.2 and the very popular Maven 2. For this article I used Maven 2.2.1 on RHEL 5.3.Setting up the environment To get started, I downloaded the Maven 2.1.1 as a compressed tar (apache-maven-2.2.1-bin.tar.gz) and unpacked it into a central location (e.g. /usr/local). Then I set the JAVA_HOME to point to the current version of Java (/usr/java/jdk1.6). Then I checked the maven version by typing: mvn -version Which displayed Along with the compiler version and OS name. Creating your first Maven project mvn archetype:generate \
my-app/src The my-app/src directory includes a sample java program (in the main subdirectory) and a test stub (in the test subdirectory). The pom.xml is the main configuration file for Maven. There is a lot of complexity and power in dissecting and understanding the POM. We'll examine the POM, in detail, in future articles, but this is not the only structure that you need to understand. Maven also creates a local repository, by default, in your $HOME/.m2 directory. It is important to become familiar with this local repository. By default, you will see a simple App.java program and a test stub called AppTest.java.
Configuring your local Maven repository The local repository is stored in a directory called ${user.home}/.m2 and stores the configuration items created by the maven build. I have seen some challenges with managing the contents of the .m2 subdirectory. For example, many people do not have much room in their home directory for large builds. You can relocate the .m2 directory by creating a ${user.home}/.m2/settings.xml and specify an alternate location for your local Maven repository: ... I have also seen files get corrupted during the build and I had to manually deleted them from the .m2 directory. Aside from the unique structure, Maven also has a unique runtime lifecycle. The Maven lifecycle It's import to understand the Maven lifecycle Here is the default lifecycle with description indicated on this link
When you run a maven build you indicate the target phase of the lifecycle and all previous steps are run first. We'll go into more detail on how to configure your POM and manage your maven builds in future articles. Please send me your own tips and tricks on Maven builds so that we can include your own best practices! Bob Aiello is the Editor-in-Chief for CM Crossroads and an independent consultant specializing in Software Process Improvement including Software Configuration and Release Management. Mr. Aiello has over 25 years experience as a technical manager in several top NYC Financial Services firms where he had had company-wide responsibility for CM, often providing hands-on technical support for enterprise Source Code Management tools, SOX/Cobit compliance, build engineering, continuous integration and automated application deployment. Bob is a long standing member of the Steering Committee of the NYC Software Process Improvement Network (CitySPIN), where he serves as the chair of the CM SIG. Mr. Aiello holds a Masters in Industrial Psychology from NYU and a B.S. in Computer Science and Math from Hofstra University. You may contact Mr. Aiello at raiello@acm.org or link with him at http://www.linkedin.com/in/bobaiello .
Set as favorite
Bookmark
Email this
Hits: 5876 Trackback(0)Comments (0)
|
|||
| Last Updated on Wednesday, 04 November 2009 10:36 |


Maven is a popular build framework that is used by many technology professionals to manage large scale java application development. The Apache Maven website (
