问题
I am writing pom.xml for our project. I need to copy two different versions of same jar. But I searched maven docs and found that Maven has no support for this. Is there any other way to do that?
Note: Both jars have same groupid and artifact id.Only their versions are different.
Thanks in advance!
回答1:
As you already know, Maven was designed to make sure that you will never have two JARs with the same coordinate (group + artifact id) but different versions on the classpath.
There is no way to achieve what you want without modifying the POMs of the JARs
So you need a workaround. Here are a couple of solutions:
Give the JARs different classifiers. Typical classifiers are "tests" and "sources" but they can be anything.
Move the version number to the artifact id and give the two JARs a new version.
For all approaches, you will need to download the JARs (and probably their POMs as well) and install them again using mvn file:install (after changing the POMs) or deploy them with mvn deploy:file if you run your own Maven proxy.
来源:https://stackoverflow.com/questions/9308366/copy-two-versions-of-same-jar-using-maven