Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

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

raghava_joijod1
Level 2
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
Hemant_arora
Correct answer by
Level 8
Level 8

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
Hemant_arora
Level 8
Level 8

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.

raghava_joijod1
Level 2
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.

Hemant_arora
Correct answer by
Level 8
Level 8

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