How to release Maven multi-module project with inter-project dependencies?

Dima picture Dima · Mar 2, 2011 · Viewed 13.6k times · Source

Lets say we have 3 layers project. DB, Business, Web and aggregating pom.

Project  
|-DB  
| |-pom.xml  
|-Business  
| |-pom.xml  
|-pom.xml

All modules are ment to be released and branched together, so Aggregator pom is configured to assign the same version to all submodules. We have the following versions:

DB-0.1-SNAPSHOT  
Business-0.1-SNAPSHOT which depends on DB-0.1-SNAPSHOT  
Web-0.1-SNAPSHOT which depends on Business-0.1-SNAPSHOT  

When doing release:prepare, all versions updated to 0.1, but prepare fails because there is no DB-0.1 in dependency yet.

One solution is to create different projects for every module and release them one by one while using versions:use-releases plugin to update dependency to 0.1

But I do not like this idea because it requires a lot of configuration and scripting. So, I prefer to use aggregation and release all modules with single command, but the problem is, as I wrote above, when release plugin tries to build Business-0.1 there is no DB-0.1 in repository yet.

Is there any way to manage these inter-project dependencies?

Thanks.

UPD:

even install goal fails.

  1. DB Build - OK (no snapshot nor release version is in any repository)
  2. Business - Failure (DB-0.1-SNAPSHOT not found in repository. But it's even not supposed to be there yet!)

I'm using maven 3.0.2 and release plugin 2.1

Answer

khmarbaise picture khmarbaise · Mar 2, 2011

your project should define the version only in the parent (project) only once. And let all other modules have a parent relationship. This means you don't have a aggregation. You have a multimodule build instead.

Project  
|-pom.xml (version 0.1-SNAPSHOT)
|-DB  
| |-pom.xml (parent: ..)
|-Business  
| |-pom.xml (parent:..)

This will solve your problem (May be you can take a look here as an example).