Maven - Module

About

module management in Maven.

A multi-module project is defined by a parent POM referencing one or more sub-modules. The mechanism in Maven that handles multi-module projects is referred to as the reactor.

A parent project with pom packaging does not have any resources, it is just a build file, that can be installed/deployed as an artifact.

Structure

The parent POM (also called the top-level POM)

<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>net.bytle</groupId>
    <artifactId>bytle-parent</artifactId>
     <version>1.0</version>
    <packaging>pom</packaging>

    <name>Multi Module Parent Project</name>

    <modules>
        <module>client</module>
        <module>application</module>
        <module>web-app</module>
    </modules>
    
    <!--Global Element such as dependency-->
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

where:

  • groupid, artifactid, version are the project Id
  • the pom packaging indicates that this is a parent PO
  • Each sub-module is represented by a sub-directory in the same directory as pom.xml

Idea

_

Documentation / Reference


Powered by ComboStrap