Maven - several dependency management artifact versions

Is there a legitimate use case for using two different versions of the same artifact in the dependency management section of your POM?

I am looking at a project whose root POM contains such an example. The project itself has several modules that use different versions of this "duplicate dependency." Some of the modules, therefore, must explicitly indicate the version of the artifact among their dependencies in order to distinguish between the two.

If POM module files should indicate version anyway, what is the reason for duplication in parent dependency management? A dependency will look right even if it has been removed from dependency management, so why do you duplicate it there first?

I'm just trying to figure out if this is good practice or is there a better solution for such a situation.

+6
source share
1 answer

In fact, if you use Maven3 +, you will get a warning similar to this:

[WARNING] [WARNING] Some problems were encountered while building the effective model for groupId:artifactId:jar:1.0-SNAPSHOT [WARNING] 'dependencyManagement.dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: junit:junit:jar -> version 3.8.1 vs 3.0 @ line 15, column 18 [WARNING] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. [WARNING] [WARNING] For this reason, future Maven versions might no longer support building such malformed projects. [WARNING] 

Maven will pick up the first, so the second will never be used. Just delete it to avoid confusion :)

+7
source

Source: https://habr.com/ru/post/952842/


All Articles