Is it possible to declare multiple versions of the same dependency in a Maven repo?
I need these dependencies all at once:
No, you can't depend 2 versions of the same artifact, normally.
But you can include them so they end up in the resulting application.
That requirement is sometimes valid - for instance, when the maintenance of that library is poor, and they rename some packages and release that as a minor version of the same artifact. Then, other projects have it as a 3rd party dependency and need the same classes under different FQCN.
For such cases, you can for instance use the maven-shade-plugin
.
shade
plugin and let it create a shaded jar. It will basically re-wrap the classes under a different artifact G:A:V.You can use different variations of the same, which, in the end, will put those classes to your classpath. For instance, use the dependency:copy-dependency
plugin/goal, and install that jar to your local repo during the build. Or unzip the classes right into your ${project.build.outputDirectory}
(target/classes).