Maven - version controlled with x, omitted for duplication?

I am having trouble understanding what is going on in the maven dependency tree when it indicates a version managed from x; omitted for duplication.

For example, suppose I have enterprise-data-2.4 defined in the server-a dependency management section.

I get the following in the server-a dependency tree for one of the server-b dependencies pulling in enterprise-data-2.4 .

 [INFO] +- hello.world.welcome.to:server-b:jar:3.1-SNAPSHOT:runtime [INFO] | +- (hello.world.where.am: enterprise-data:jar:2.4:runtime - version managed from 3.0; omitted for duplicate) 

Assuming server-b is the only jar pulling enterprise-data-2.4 , I understand that server-a will always pull enterprise-data-2.4 here. Is it correct?

However, I have code in server-b that depends on enterprise-data-3.0 , and server-b has compile-time dependency on enterprise-data-3.0 .

Now I have a test project, say test-b , which tests the server-b jar present inside the server-a project and has a test dependency on enterprise-data-3.0 . These tests directly fall into the code present on server-a .

When I run my tests in test-b , I should get errors when trying to access the functions present in enterprise-data-3.0 , since it does not get pulled into server-a or will it pass because there is a test dependency on enterprise-data-3.0 ? It is currently undergoing, but I'm not sure how sufficient the test dependency is.

Please help me understand.

Edit: I am using maven-3 .

Thanks.

+8
java maven dependency-management
source share
1 answer

For example, suppose I have enterprise-data-2.4 data defined in the server-a dependency management section.

Then you always get 2.4, even if there is only a JAR depending on 1.8. Dependency management redefines interdependence.

Assuming server-b is the only bank holding enterprise-data-2.4 data, I understand that server-a will always retrieve enterprise-data-2.4 data here. Is it correct?

Assuming you have no dependency management, then yes. If there are several dependencies depending on different versions, then the question is which one (and its transitive dependencies) is loaded first, in accordance with the rules for dependency mediation for version Maven> 2.0.9. Others will be: "manipulated with x and omitted for duplication."

When I run my tests in test-b, I should get errors when trying to access the functions present in Enterprise-data-3.0, because it is not delayed by server-a or will it pass because there is a test dependency on the enterprise -data- 3.0? It is currently undergoing, but I'm not sure how sufficient the test dependency is.

If it pulls the wrong version with incompatible code, yes, you will see errors. For Maven 3, defining a scope test dependency with 3.0 and compiling a dependency on a 2.4 level means that Maven overrides 2.4 and moves on with a new one defined in the scan scope. See this question and its answers for more details.

However, you can always use the dependency management in test-b to fix the version of each dependency that you want to use.

+3
source share

All Articles