4

I have a maven-java project (say Project A) with a parent defining modules in its pom. I also have an external project (say Project B) that requires dependencies of two of the modules from Project A. For now, i have defined the dependency to pull each module individually. When i replace these two with a dependency on the parent pom, it errors out on build. Is there some modification i need to make to my parent pom of Project A to make this work?

Can this be done in the first place?

Brian Webster
  • 30,033
  • 48
  • 152
  • 225

1 Answers1

2

Can this be done in the first place?

Declaring a dependency on an aggregating POM won't get the modules transitively. This is not going to work. It is possible to create a POM to group dependencies though.

For example, EHCache uses this technique. As mentioned in their documentation:

Maven Snippet

To include Ehcache in your project use:

   <dependency>
       <groupId>net.sf.ehcache</groupId>
       <artifactId>ehcache</artifactId>
       <version>2.0.1</version>
       <type>pom</type>
   </dependency>

The net.sf.ehcache:ehcache artifact is precisely used to group dependencies (and is distinct from net.sf.ehcache:ehcache-parent).

References

Brian Webster
  • 30,033
  • 48
  • 152
  • 225
Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • Great! I will probably go with the grouping the modules in a new pom as deps and referencing that one. Thankyou! – rainInSpain Nov 10 '10 at 06:11