Reputation: 2228
Is it possible in maven project to sepecify in the dependecies, which one is applied for which java package ? If it's possible how ?
Example: I have two package:
1) org.test.compute
2) org.test.stock
And dependencies are:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.9.35</version>
</dependency>
<dependency>
<groupId>org.cloudfoundry</groupId>
<artifactId>cloudfoundry-client-lib</artifactId>
<version>1.0.0</version>
</dependency>
my goal is:
aws-java-sdk applied to org.test.compute
and org.cloudfoundry to org.test.stock
Upvotes: 1
Views: 73
Reputation: 23562
No, you can't. All packages of a Java application are included in the same runtime classpath, so all of the dependencies that are on the classpath are visible in all of the packages.
Upvotes: 2
Reputation: 5168
If it's only because there is two classes with the same name in the two dependencies, I suggest to use full qualified names when you're using the classes like:
org.cloudfoundry.pathA.classA
com.amazonaws.pathB.classA
Also, if the dependencies are only used in the test classes, you want to use the test scope like this:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.9.35</version>
<scope>test</scope>
</dependency>
By doing so, the dependecy will be only used while compiling and running the tests. It will not be included in the final WAR or EAR file.
Upvotes: 1
Reputation: 70
You can achieve this by using a multi-module project in maven.
https://maven.apache.org/guides/mini/guide-multiple-modules.html
Upvotes: 2