使用maven复制同一个jar的两个版本 [英] Copy two versions of same jar using maven

查看:875
本文介绍了使用maven复制同一个jar的两个版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我们的项目编写pom.xml。我需要复制同一个jar的两个不同版本。但我搜索maven文档,发现Maven不支持这个。有没有其他方法可以做到这一点?

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?

注意:两个jar有相同的groupid和artifact id.Only他们的版本是不同的。

Note: Both jars have same groupid and artifact id.Only their versions are different.

提前感谢!

推荐答案

正如你已经知道的,Maven的目的是确保你永远不会有两个具有相同坐标(组+工件id)但在类路径上有不同版本的JAR。

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.

没有办法实现你想要的而不修改JAR的POM

因此,您需要一个解决方法。这里有几个解决方案:

So you need a workaround. Here are a couple of solutions:


  1. 给JAR不同的分类器。典型的分类器是测试和来源,但它们可以是任何内容。

  1. Give the JARs different classifiers. Typical classifiers are "tests" and "sources" but they can be anything.

将版本号移动到工件ID并给予两个JAR

Move the version number to the artifact id and give the two JARs a new version.

对于所有方法,您需要下载JAR(也可能是他们的POM)再次使用 mvn file:install (更改POM之后)或使用 mvn deploy:file 部署自己的Maven代理。

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.

这篇关于使用maven复制同一个jar的两个版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆