Reputation: 12416
I would like to be able to define set of dependencies in parent pom and to be able to include these sets in children poms.
For instance:
parent pom {
set1 {artifact1, artifact2, artifact3}
set2 {artifact4, artifact5}
set3 {artifact6, artifact7}
}
child1 pom {
dependencies {set1, set2}
}
child2 pom {
dependencies {set2, set3}
}
This behaviour is also described here (not implemented): http://docs.codehaus.org/display/MAVEN/Profiles+for+optional+dependencies
Is there any way to do this? Thanks!
Upvotes: 1
Views: 68
Reputation: 13978
I don't think there is a way to achieve what you want via parent/child relationship of POMs (although would be glad to be corrected on this), but one solution that might work for you is to define groups of dependencies in their own POM file and then add a dependency to this POM in your individual modules.
So for example, here is a POM definition for some Spring dependencies:
<groupId>com.xyz</groupId>
<artifactId>spring-deps</artifactId>
<version>SNAPSHOT</version>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
</dependencies>
Then in your module's pom you define a dependency to this pom:
<groupId>com.xyz</groupId>
<artifactId>module1</artifactId>
<version>SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.xyz</groupId>
<artifactId>spring-deps</artifactId>
<version>SNAPSHOT</version>
<type>pom</type>
</dependency>
</dependencies>
and all the Spring dependencies defined in the spring-deps pom are automatically included for you.
Upvotes: 2