Maven pom.xml

From NovaOrdis Knowledge Base
Revision as of 06:15, 2 January 2017 by Ovidiu (talk | contribs)
Jump to navigation Jump to search

External

Internal

Overview

<project> is the root element.

Example

Simple pom.xml Example

Elements

<modelVersion>

Mandatory. Should be:

<modelVersion>4.0.0</modelVersion>

<groupId>

Mandatory. For more details about Group ID, see Maven Concepts - Group ID.

<artifactId>

Mandatory. For more details about Artifact ID, see Maven Concepts - Artifact ID.

<version>

Mandatory. For more details about Version, see Maven Concepts - Version.

<packaging>

Optional, the default value is "jar". For more details about packaging, see Maven Concepts - Packaging.

<classifier>

Optional. For more details about packaging, see Maven Concepts - Classifier.

<name>

Optional.

If specified, will be used in the "Reactor Summary" report, generated at the end of the build.

IntelliJ IDEA will use it as the project name, the text that will show up at the top of the editor window.

See <artifactId> and Maven Concepts - Name.

<properties>

Maven Custom System Properties


<modules>

<dependencyManagement>

For more details about dependency management, see:

Dependency Management Concepts

Example:

<dependencyManagement>
    <dependencies>
        <dependency>
           <groupId>org.slf4j</groupId>
           <artifactId>slf4j-api</artifactId>
           <version>1.7.6</version>
        </dependency>
   </dependencies>
</dependencyManagement>

<build>

<finalName>

<finalName> can be used to customize the name of the artifact. The value allows for system properties (standard or custom), as in the following examples:

<build>
    <finalName>simple-webapp</finalName>
</build>
<build>
    <finalName>${artifactId}</finalName>
</build>
<build>
    <finalName>archimedes-${project.version}</finalName>
</build>
<build>
    <finalName>${parent.artifactId}-${artifactId}</finalName>
</build>

finalName modifies the name of the artifact created in the local target directory of the project. However, irrespective of using finalName, Maven will still install conventionally named artifacts in the repository.

For more details on artifact name, see:

Artifact Name

For considerations of using <finalName> as part of an assembly plug-in configuration, see:

<finalName> and the assembly plugin

<plugins>

https://maven.apache.org/pom.html#Plugins

The <plugins> container specifies the list of plugins to be used for the current project, along with their configuration.

<pluginManagement>

https://maven.apache.org/pom.html#Plugin_Management

The <pluginManagement> container is also a list of plugins, similar to <plugins>, but rather than configuring plugin information for this specific project, it is intended to configure project builds that inherit from the POM that specifies it. When a plugin is configured in the parent POM <pluginManagement>, it can be referred from the child's <plugins>, recursively, by name and without any configuration. The reference, however, must exists in the child's <plugins> for the plugin to be associated with the child's build. The reference consists in the plugin's <groupId> and plugin's <artifactId>. Children can override the <pluginManagement> definitions.