我如何获得一个maven软件包命令将产生的GAV列表? [英] How can I get a list of GAVs a maven package command will produce?

查看:148
本文介绍了我如何获得一个maven软件包命令将产生的GAV列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个(受支持的)基于mvn的命令,它将为我提供运行mvn package命令将产生的所有工件的所有GroupID:ArtifactID:Version(GAV)的列表.

I'm looking for a (supported) mvn based command, which will give me a list of all the GroupID:ArtifactID:Version (GAV) for all artifacts that running a mvn package command would produce.

对于没有父pom的单个模块Maven项目,这很简单:您可以查看pom的内部.

For a single module Maven project, with no parent pom, this is trivial: you can look inside the pom.

对于具有父pom的单个模块Maven项目,您可以使用help:effective-pom,它将显示一个带有<version>元素的pom文件.

For a single module Maven project, with a parent pom, you could use help:effective-pom and it will present a pom file with the <version> element present.

对于多模块Maven项目(反应堆),您实际上可以执行相同的操作(不是这样,只是通过尝试一下就知道了).这将允许为(多个)<project>元素解析文件.

For a multi module Maven project (reactor), you could actually do the same (didn't think so, learned so just now by trying it out). This will allow parsing the file for (multiple) <project> elements.

还有什么需要考虑的吗?

Anything else to consider?

此操作的总体目标是能够提供下游的持续交付服务( http://go.cd/)阶段/步骤/作业以及应该使用哪个版本的上游依赖项的信息.

The overall goal of this, is to be able to feed a downstream Continuous Delivery (http://go.cd/) stage/step/job with information on what version of it's upstream dependencies should be used.

推荐答案

通常,您无法在构建运行之前生成列表...问题是,基于pom模型,并非所有工件都得到了描述,原因是一些插件可以产生补充工件(maven-assembly-plugin,maven-shade-plugin,maven-jar-plugin通过test-jar等)

In general you can't produce a list before the build has run...The problem is that based on the pom model not all artifacts are described, cause some plugins can produce supplemental artifacts (maven-assembly-plugin, maven-shade-plugin, maven-jar-plugin via test-jar etc.)

您可以做的是在运行构建后获取生成的工件的列表.(已安装).您的问题启发了我实施EventSpy ,该事件会在构建...看起来像这样:

What you can make is to get a list of produced artifacts after a build has run..(installed). The question of yours inspired me to implement an EventSpy which produces such list at the end of the build...which looks like this:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.423 s
[INFO] Finished at: 2016-05-08T13:22:10+02:00
[INFO] Final Memory: 24M/310M
[INFO] ------------------------------------------------------------------------
[INFO] --             Maven Artifact Collector Summary                       --
[INFO] ------------------------------------------------------------------------
[INFO] test.maven.plugin.profiler:parse-pom:0.1.0-SNAPSHOT:jar
[INFO] test.maven.plugin.profiler:parse-pom:0.1.0-SNAPSHOT:pom
[INFO] test.maven.plugin.profiler:parse-pom:0.1.0-SNAPSHOT:jar:jar-with-dependencies

我所能做的就是增强它并编写一个包含信息的文件(或多或少以任何格式)...此刻它只是一个PoC ...也许您可以提供更多信息或创建问题或PR并要求可能需要的内容...也许这对其他人也很有趣...

What i can do is to enhance that and write a file which contains the information (in more or less any format)...At the moment it's just a PoC...May be you can give some more information or create issues or PR's and request what might be needed...may be this is also interesting for others...

此外,您的下游部分必须在存储库高速缓存中具有可用的工件(通过文件系统或通过存储库管理器或docker数据容器)...

Furthermore your downstream part must have those artifacts within a repository cache available (either on a file system or via a repository manager or docker data container)...

这篇关于我如何获得一个maven软件包命令将产生的GAV列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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