英文:
Maven publish & consume the third-party runtime jars while building our own custom.jar
问题
我有一个Maven项目,我们正在使用S3存储库加载内部的abc-1.0.jar
,以及abc-1.0.jar
所需的任何运行时依赖项,我们以.zip
的形式加载,并将其解压缩,如下所示:
有趣的注: 当我说第三方运行时jar包是一个zip时,有些jar包可能在构建abc-1.0.jar
时没有被使用过。
project.zip
-- lib
-- abc-1.0.jar
-- runtime_jars_for_abc.jar
-- runtime_jars_for_project.jar
有可能当将abc-1.0.jar
交付到my-project
时,运行时zip可能会有一组jar
,但对于abc-2.0.jar
,我需要提供另一组jar
。
我通过以zip的形式进行交付并在创建project.zip
时进行解压缩来解决了这个问题。
但是,是否有可能我可以将这些runtime.jar
与我的abc-1.0.jar
或abc-2.0.jar
一起发布或公告,以便my-project/pom.xml
可以在运行时从mavenCentral()
或我的内部maven-repo
中动态地获取这些公告?
编辑
我在这里找到了maven changes插件
https://maven.apache.org/plugins/maven-changes-plugin/。这在很大程度上将发布新的变更,但我如何在每次新构建时动态地消耗这些新变更呢? 有什么想法吗? 🤔
*我想的是将abc-1.0.jar
与其abc-1.0-pom.xml
文件一起推送,该文件应该包含一些自定义范围或依赖jar的逻辑分组,以便我可以在消费项目中指定那些自定义范围
或分组
,并使用maven copy dependencies插件
https://maven.apache.org/plugins/maven-dependency-plugin/examples/copying-project-dependencies.html 来独特地复制那些jar,但不幸的是,Maven不支持自定义范围
😞
英文:
I've a maven project for which we are loading internal abc-1.0.jar
using S3 repository and whatever runtime dependencies requires for abc-1.0.jar
to be a part of my project, we load in the form of .zip
and extract it as
Interesting Note: When I say third-party runtime jars as a zip, there are some jars which might not have used while building abc-1.0.jar
project.zip
-- lib
-- abc-1.0.jar
-- runtime_jars_for_abc.jar
-- runtime_jars_for_project.jar
There is possibility that when deliver abc-1.0.jar
jar to my-project
the runtime zip might have one set of jars
but for abc-2.0.jar
I need to ship another set of jars
.
I've solved the problem by shipping it in the form of zip and extracting it while creating the project.zip
But, is it possible that I can ship or announce those runtime.jar
along with my abc-1.0.jar
or abc-2.0.jar
so that my-project/pom.xml
can consume that announcement on the fly from either mavenCentral()
or my internal maven-repo
?
EDIT
I found maven changes plugin
here https://maven.apache.org/plugins/maven-changes-plugin/. this is mostly going to publish the new changes but how can I dynamically consume the new changes for each new build? any thoughts? 🤔
*What I was thinking is to push the abc-1.0.jar
along with it's abc-1.0-pom.xml
file which should consist of some custom scope or logical grouping of dependent jar, so that I can specify those custom scopes
or groups
in consumption project to uniquely copy those jars using maven copy dependencies plugin
https://maven.apache.org/plugins/maven-dependency-plugin/examples/copying-project-dependencies.html but unfortunately maven doesn't support custom scopes
😞
答案1
得分: 1
在你的项目b中,在版本前面加上 -SNAPSHOT,就像这样:
<groupId>my.groupid</groupId>
<artifactId>my.artifactid</artifactId>
<version>0.0.1-SNAPSHOT</version>
因此,每当你在项目b中进行更新时,你的项目a将从Maven仓库中选择最新的快照版本。
正如你所看到的,Maven通过添加时间戳来组织快照,以便提供最新的发布。
请注意,你的项目a绝不能将快照依赖项用于验收、预生产或生产环境!
英文:
In your project-b, prefix your version by -SNAPSHOT, like this
<groupId>my.groupid</groupId>
<artifactId>my.artifactid</artifactId>
<version>0.0.1-SNAPSHOT</version>
So, every time when you do update in your project-b, your project-a will pick the latest snapshot from maven repository
As you can see, maven organize snapshot by adding a timestamp to deliver the latest publish
Note that your project-a must never go to acceptance, pprod or production environment with snapshot dependencies !
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论