2

Assuming that I have an artifact my-project-core that includes some dependencies with library:

<artifactId>my-project-core</artifactId>
<name>CORE</name>

...

<dependency>
    <groupId>com.bun.puffy</groupId>
    <artifactId>just-the-lib</artifactId>
    <version>1.0.0</version>
</dependency>

And I want to use it in new project that have dependency with my-project-core

<artifactId>new-project-using-core</artifactId>
<name>NEW PROJECT USING CORE</name>

...

<dependency>
    <groupId>com.bun.puffy</groupId>
    <artifactId>my-project-core</artifactId>
    <version>1.0.0</version>
</dependency>

<!-- should I also add this ?
<dependency>
    <groupId>com.bun.puffy</groupId>
    <artifactId>just-the-lib</artifactId>
    <version>1.0.0</version>
</dependency>
-->

should I add dependency for just-the-lib in the new project or should I not do this and depend on the dependency of my-project-core? What are pros and cons?

puffy.bun
  • 256
  • 1
  • 10
  • 3
    No, the dependency my-project-core will bring all it needs automatically. – Essex Boy Nov 30 '18 at 12:35
  • 2
    One exception is: Do you use some classes of the just-the-lib than add otherwise keep it as it. – khmarbaise Nov 30 '18 at 12:42
  • 1
    As khmarbaise says, if you use apis from just-the-lib, it should be added. Please also see this answer: https://stackoverflow.com/questions/53200029/should-you-include-those-dependencies-in-your-pom-that-are-already-the-dependenc/53203321#53203321 – gjoranv Nov 30 '18 at 15:36
  • @gjoranv thank you :) – puffy.bun Nov 30 '18 at 15:59
  • I think `mvn dependency:analyze` will tell you if your app is directly using classes from a lib that is being included as a transitive dependency (the case @khmarbaise and @gjoranv mention) instead of being directly referenced in the app's POM. – user944849 Nov 30 '18 at 16:44

0 Answers0