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>[email protected]</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>