Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Why can't transitive dependency on Uber jar be achieved?

Avatar

Level 2

According to the concept of transitive dependency, if a project, say it A has dependency on X jar and is included in A's pom.xml. Now my second project, say it B has dependency on both project A and X jar. So now in my B's pom.xml I'll add only project B in its dependency, as X jar is served by A by concept of transitive dependency.

But instead of X jar if I have an Uber(shaded) jar then when I build project B, it fails saying packages included in Uber jar are missing. Means the concept is failing.

Please help me understand if I'm missing any concept or miss understanding transitive dependency.

1 Accepted Solution

Avatar

Correct answer by
Level 9

I believe you need to change the dependency scope to compile instead of provided.

because provided scope is only available on the compilation and test classpath, and is not transitive.

refer to Maven – Introduction to the Dependency Mechanism

View solution in original post

4 Replies

Avatar

Level 9

I think you want to say "So now in my B's pom.xml I'll add only project A in its dependency, as X jar is served by A by concept of transitive dependency."

What value are you defining in dependency scope ?

Yes transitive dependencies work the way you explained but dependency scope,mediation,exclusions can limit the transitivity of a dependency, and also to affect the classpath used for various build tasks.

So make sure you are using the correct dependency scope, mediation or exclusions.

Avatar

Level 2

The X jar i'm referring is UBER Jar,

<dependency>

          <groupId>com.adobe.aem</groupId>

          <artifactId>uber-jar</artifactId>

          <version>6.3.0</version>

          <classifier>apis</classifier>

          <scope>provided</scope>

</dependency>

My Project A's pom.xml includes this (uber jar) in dependencies section.

My Project B has project A in its dependencies, but i still need to add the uber jars dependency in project B's dependencies section to build successfully.

My Question here is why do I need to include uber jars dependency in project B, i'm expecting that it will be served by Project A as I have included it in project A's dependency.

Avatar

Correct answer by
Level 9

I believe you need to change the dependency scope to compile instead of provided.

because provided scope is only available on the compilation and test classpath, and is not transitive.

refer to Maven – Introduction to the Dependency Mechanism