このコンテンツは選択した言語では利用できません。

2.3. Create an Aggregate Maven Project


Aggregate POM

A complete application typically consists of multiple Maven projects. As the number of projects grows larger, however, it becomes a nuisance to build each project separately. Moreover, it is usually necessary to build the projects in a certain order and the developer must remember to observe the correct build order.
To simplify building multiple projects, you can optionally create an aggregate Maven project. This consists of a single POM file (the aggregate POM), usually in the parent directory of the individual projects. The POM file specifies which sub-projects (or modules) to build and builds them in the specified order.

Parent POM

Maven also supports the notion of a parent POM. A parent POM enables you to define an inheritance style relationship between POMs. POM files at the bottom of the hierarchy declare that they inherit from a specific parent POM. The parent POM can then be used to share certain properties and details of configuration.
Important
The details of how to define and use a parent POM are beyond the scope of this guide, but it is important to be aware that a parent POM and an aggregate POM are not the same thing.

Best practice

Quite often, you will see examples where a POM is used both as a parent POM and an aggregate POM. This is acceptable for small, relatively simple applications, but is not recommended as best practice. Best practice is to define separate POM files for the parent POM and the aggregate POM.

Create an aggregate POM

To create an aggregate POM for your getting started application, use a text editor to create a pom.xml file in the get-started directory and add the following contents to the file:
<?xml version="1.0" encoding="UTF-8"?>
<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">
  
  <groupId>org.fusesource.example</groupId>
  <artifactId>get-started</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>pom</packaging>
  <modelVersion>4.0.0</modelVersion>

  <name>Getting Started :: Aggregate POM</name>
  <description>Getting Started example</description>

  
  <modules>
    <module>cxf-basic</module>
    <module>camel-basic</module>
  </modules>
  

</project>
Copy to Clipboard Toggle word wrap
As with any other POM, the groupId, artifactId, and version must be defined, in order to identify this artifact uniquely. But the packaging must be set to pom. The key portion of the aggregate POM is the modules element, which defines the list of Maven sub-projects to build and defines the order in which the projects are built. The content of each module element is the relative path of a directory containing a Maven project.

Building with the aggregate POM

Using the aggregate POM you can build all of sub-projects in one go, by entering the following at a command prompt:
cd get-started
mvn install
Copy to Clipboard Toggle word wrap
トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2025 Red Hat