18
Use Maven in Right Way Make build configurations effective with dependencyManagement, pluginManagement and profiles Monday, May 21, 12

Use maven in_right_way

Embed Size (px)

Citation preview

Use Maven in Right Way

Make build configurations effective with dependencyManagement,

pluginManagement and profiles

Monday, May 21, 12

<dependency> <groupId>my-group1</groupId> <artifactId>artifact</artifactId> <version>1.0</version></dependency>

Typical Dependency

Monday, May 21, 12

<dependency> <groupId>my-group1</groupId> <artifactId>artifact</artifactId> <version>1.0</version></dependency>

Typical Dependency

Monday, May 21, 12

Problem Set

20 dependencies chaotically distributed per 5 modules

Review all modules to make change in dependency

The worst case it takes 6 reviews

The worst case it takes 120 changes

Monday, May 21, 12

Version in property

<artifact.version>1.0</artifact.version>

<dependency> <groupId>my-group1</groupId> <artifactId>artifact</artifactId> <version>${artifact.version}</version></dependency>

Monday, May 21, 12

Extended Dependency

<dependency> <groupId>my-group1</groupId> <artifactId>artifact</artifactId> <version>${artifact.version}</version> <scope>provided</scope> <classifier>jdk15</classifier> <optional>true</optional> <packaging>zip</packaging></dependency>

Monday, May 21, 12

Exclusions<dependency> <groupId>my-group1</groupId> <artifactId>artifact</artifactId> ... <exclusions> <exclusion> <groupId>exclude-group</groupId> <groupId>exclude</groupId> </exclusion> </exclusions></dependency>

Monday, May 21, 12

Inject Management

Monday, May 21, 12

Solution 1

All dependency configuration in one place

The worst case it takes 1 review to change ANY property of ANY dependency

The worst case it takes 20 changes

Monday, May 21, 12

Typical Plugin<build> <plugins> <plugin> <groupId>plugin-group</groupId> <artifactId>plugin</artifactId> <version>1.0</version> <configuration>...</configuration> <executions>...</executions> </plugin> </plugins></build>

Monday, May 21, 12

Problem Set 2

10 plugins chaotically distributed per 5 modules

Duplicates

The worst case it takes 6 reviews to update plugins

The worst case it takes 240 changes

Monday, May 21, 12

Inject Management

Monday, May 21, 12

Solution 2

All plugins defines in one place

NO DUPLICATES

In the worst case it takes 1 review to update plugins

In the worst case it takes 40 changes

Monday, May 21, 12

Monday, May 21, 12

One more thing...

Monday, May 21, 12

Problem Set 3

Separate unit tests and integration tests

Integration environment to run integration tests ONLY

Monday, May 21, 12

Solution 3

Integration profile

Common configuration in default pluginManagement

Executions & configuration customization in profile

Monday, May 21, 12

Thank you!

Anton Naumovemail: [email protected]

twitter: antonnaumovblog: http://antonnaumov.posterous.com

Monday, May 21, 12