Enterprise Java Development@TOPIC@
Defines what is possible without actively imposing the dependency or plugin defined
Placed in a parent of multi-module project
Consolidate management of dependency versions without adding active dependencies to all inheriting children
<properties>
<junit.version>4.12</junit.version>
<log4j.version>1.2.17</log4j.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
...
</dependencies>
</dependencyManagement>
Parent defines dependency versions for two artifacts (passive)
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Child declares a dependency on one of the artifacts (active)
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
Net result is a consistent version for dependency in effective pom
$ mvn help:effective-pom
Control artifact versions used in transitive dependencies
Exclude artifacts from transitive dependencies
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.jbossas</groupId>
<artifactId>jboss-as-server</artifactId>
<version>${jboss-as-server.version}</version>
<classifier>jmx-invoker-adaptor-client</classifier>
<exclusions>
<exclusion> <!-- gets in the way with JBoss6 and M2 -->
<groupId>org.jboss.security</groupId>
<artifactId>jbosssx-client</artifactId>
</exclusion>
<exclusion> <!-- gets in the way with newer versions -->
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
Parent defines exclusions for possible dependency (passive)
using dependencyManagement
<dependencies>
<dependency>
<groupId>org.jboss.jbossas</groupId>
<artifactId>jboss-as-server</artifactId>
<classifier>jmx-invoker-adaptor-client</classifier>
</dependency>
Child includes simple dependency declaration (active)
using dependencies
Consolidate management of plugin versions and default configuration without adding activations to all inheriting children
<properties>
<java.source.version>1.8</java.source.version>
<java.target.version>1.8</java.target.version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.source.version}</source>
<target>${java.target.version}</target>
</configuration>
</plugin>
...
</plugins>
</pluginManagement>
</build>
Parent defines version for compiler plugin and configures for Java 8
<parent>
<groupId>info.ejava.examples.javase</groupId>
<artifactId>javase</artifactId>
<version>5.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>ejava.javaee.intro</groupId>
<artifactId>javase5Enhancements</artifactId>
<packaging>jar</packaging>
Child of packaging=jar type automatically get compiler configured to parent specs
A more complicated example
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>${cargo-maven2-plugin.version}</version>
<configuration>
<container>
<containerId>${cargo.containerId}</containerId>
<type>remote</type>
<log>target/server.log</log>
<output>target/output.log</output>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.hostname>${jboss.mgmt.host}</cargo.hostname>
<cargo.jboss.management.port>${jboss.mgmt.port}</cargo.jboss.management.port>
</properties>
</configuration>
</configuration>
<dependencies>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-controller-client</artifactId>
<version>${jboss.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>cargo-prep</id>
<phase>pre-integration-test</phase>
<goals>
<goal>redeploy</goal>
</goals>
</execution>
<execution>
<id>cargo-post</id>
<phase>post-integration-test</phase>
<goals>
<goal>undeploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
Parent defines details of deployment to JBoss container (passive)
using dependencyManagement
<build>
<plugins>
<!-- artifacts to deploy to server -->
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>ejbsessionBankEAR</artifactId>
<type>ear</type>
</deployable>
</deployables>
</configuration>
</plugin>
...
</plugins>
</build>
Child declares plugin (active) in plugins
with configuration extensions specific to child project