Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top