In my previous article I introduced Maven, the maven cycle and discussed the local repository. Maven has a lot of implied structure that you need to be aware of or you just won’t understand why things are happening behind the scenes. While Maven is great is presenting a consistent set of standards, sometimes it can be hard to figure out what happening behind the scenes. POMs are key to directing maven to do your bidding, they can also be a real challenge to decipher.
The Maven POM The Project Object Model (POM) is an XML file that you can use to indicate what you need Maven to do for a particular project. The Maven POM contains configuration information about the project that are interpreted by Maven during the Maven Lifecycle to build (and optionally, deploy) the project. Maven assumes many default values in its attempt to focus on standard conventions.
Cascading POMs In any project, Maven looks for the POM in the current directory and then follows the directives to executive plugins and goals as needed. In practice, you are likely to have many POMs in your directory structure. The POM inherits values from the parent POM which may or may not be desirable. Fortunately, you can override values as needed. The Maven POM inherits lots of information from the parent POM including identifiers, dependencies, developers & contributors, plugin & report lists, plugin executions, and plugin configuration. We’ll take a look at each of these in upcoming articles. POMs inherit from parents, they also inherit values from the Super POM.
Super POM All POMs extend from the default Maven Super POM unless explicitly set otherwise. This means that the configuration specified in the Super POM is inherited by the POMs you created for your projects. You can find copies of the Super POM for Maven 2.0.x. on the maven.apache.org website (http://maven.apache.org).
Focus on the Project Maven is not just a build tool. It is a comprehensive framework that provides extensive information on the application that is being built. The command:
mvn site
generates documents and reports on the project that is being described in the POM. When you execute this command you will see an index.html file that can be used to post information on your project. (I should also mention that the first time that you execute this command maven will automatically download plugins to support the “mvn site” command.) Here is how the run might look for a second run of this command:
|
> mvn site
[INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building my-app [INFO] task-segment: [site] [INFO] ------------------------------------------------------------------------ [INFO] [site:site {execution: default-site}] [INFO] Generating "About" report. [INFO] Generating "Issue Tracking" report. [INFO] Generating "Project Team" report. [INFO] Generating "Dependencies" report. [INFO] Generating "Continuous Integration" report. [INFO] Generating "Source Repository" report. [INFO] Generating "Project License" report. [INFO] Generating "Mailing Lists" report. [INFO] Generating "Plugin Management" report. [INFO] Generating "Project Summary" report. [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 28 seconds [INFO] Finished at: Sun Nov 29 16:33:28 EST 2009 [INFO] Final Memory: 23M/180M [INFO] ------------------------------------------------------------------------
|
Now you will have the pom.xml, the src directory and a new directory called “target” containing the website site html that you have created.
|
target target/site target/site/images target/site/images/external.png target/site/images/icon_error_sml.gif target/site/images/logos target/site/images/logos/build-by-maven-black.png target/site/images/logos/maven-feather.png target/site/images/logos/build-by-maven-white.png target/site/images/collapsed.gif target/site/images/icon_success_sml.gif target/site/images/expanded.gif target/site/images/icon_warning_sml.gif target/site/images/icon_info_sml.gif target/site/images/close.gif target/site/images/newwindow.png target/site/mail-lists.html target/site/css target/site/css/maven-theme.css target/site/css/site.css target/site/css/print.css target/site/css/maven-base.css target/site/source-repository.html target/site/team-list.html target/site/dependencies.html target/site/issue-tracking.html target/site/project-info.html target/site/project-summary.html target/site/index.html target/site/license.html target/site/plugin-management.html target/site/integration.html target/site target/site/images target/site/images/external.png target/site/images/icon_error_sml.gif target/site/images/logos target/site/images/logos/build-by-maven-black.png target/site/images/logos/maven-feather.png target/site/images/logos/build-by-maven-white.png target/site/images/collapsed.gif target/site/images/icon_success_sml.gif target/site/images/expanded.gif target/site/images/icon_warning_sml.gif target/site/images/icon_info_sml.gif target/site/images/close.gif target/site/images/newwindow.png target/site/mail-lists.html target/site/css target/site/css/maven-theme.css target/site/css/site.css target/site/css/print.css target/site/css/maven-base.css target/site/source-repository.html target/site/team-list.html target/site/dependencies.html target/site/issue-tracking.html target/site/project-info.html target/site/project-summary.html target/site/index.html target/site/license.html target/site/plugin-management.html target/site/integration.html
|
Your site will include the following information:
About
Continuous Integration
Dependencies
Issue Tracking
Mailing Lists Plugin Management Project License
Project Summary Project Team
Source Repository
I have seen continuous integration projects where the project was built using maven and then automatically generated documentation and posted to a website. Maven is a very comprehensive framework, with a bit of a learning curve and also many features that can help you establish excellent build engineering practices. Please send me your own Maven tips, tricks and challenges!
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 .
Trackback(0)
Comments 
Write comment
 |