FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
Architecture & Design
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
April 21, 2006

Maven: Building Complex Systems

(Page 5 of 8)

Multi-module Builds

The POM (Project Object Model) is kind of a misnomer because in multi-module projects every module will have its own POM in a separate pom.xml file. I guess MOM (Module Object Model) sounds silly to tough and brawny Maven developers. The documentation mentions a super POM, but I couldn't figure out if they mean the set of all elements that may appear in a POM or the top-level POM so I will not use the "super POM" term. The top-level POM file (see Listing Three) specifies a <modules> element that defines the build order. When Maven encounters a <modules> element it drops whatever it's doing and starts building the modules. You may have <modules> elements in intermediate POMs too and create a controlled cascading build. The build order is: SudokuSolver and then SudokuServer. It makes sense since SudokuServer depends on SudokuSolver, so SudokuSolver must be built first. The dependency resolution mechanism doesn't resolve this case automatically since both modules are siblings.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>GigiZone</groupId>
  <artifactId>Sudoku</artifactId>
  <version>1.0-SNAPSHOT</version>
  <name>Sudoku Parent POM</name>
  <url>http://localhost:8080/SudokuServer-1.0-SNAPSHOT/sudoku.html</url>
  <packaging>pom</packaging>  
  <modules>
  	<module>SudokuSolver</module>
  	<module>SudokuServer</module>
  </modules>
  <developers>
    <developer>
      <name>Gigi Sayfan</name>
      <email>gsayfan@playstation.sony.com</email>
      <roles>
        <role>Lead Developer</role>
      </roles>
      <timezone>0</timezone>
    </developer>
  </developers>  
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
           <source>1.5</source>
           <target>1.5</target>
        </configuration>
     </plugin>
    </plugins>  
  </build>  
  <repositories>
    <repository>
      <id>Maven Snapshots</id>
      <url>http://snapshots.maven.codehaus.org/maven2/</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <releases>
        <enabled>false</enabled>
      </releases>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <id>Maven Snapshots</id>
      <url>http://snapshots.maven.codehaus.org/maven2/</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <releases>
        <enabled>false</enabled>
      </releases>
    </pluginRepository>
  </pluginRepositories>  
  
</project>

Listing Three: Top-level POM file.

Previous Page | 1 Introducing Maven | 2 What Is Maven? | 3 The Project Object Model | 4 Maven At Work | 5 Multi-module Builds | 6 Configuring Plugins | 7 SudokuServer: A Sample Web Application | 8 Complete Source Code Next Page
TOP 5 ARTICLES
No Top Articles.



MICROSITES
FEATURED TOPIC

ADDITIONAL TOPICS

INFO-LINK