gpt4 book ai didi

Building specific modules in multimodular maven project + dependencies conditionally(在多模块Maven项目+依赖项中有条件地构建特定模块)

转载 作者:bug小助手 更新时间:2023-10-25 23:47:09 26 4
gpt4 key购买 nike



When running mvn install -pl "project1, project2, etc." -am -Pmy-profile, maven will build the specified modules and all their dependencies which can take a while if there are a lot of dependencies.

当运行MVN安装-pl“项目1,项目2等”-am-Pmy-Profile时,maven将构建指定的模块及其所有依赖项,如果存在大量依赖项,这可能需要一段时间。


That being said, some dependencies being compiled (due to the -am flag) may already exist in the local .m2 repository and/or in my-profile, rendering their recompilation useless and often time consuming.

也就是说,一些正在编译的依赖项(由于-am标志)可能已经存在于本地.m2存储库和/或my-Profile中,这使得它们的重新编译毫无用处,而且往往很耗时。


Is there any way to specify that maven should only build a given -am dependency if it does not already exist in my-profile nor locally in .m2?

有没有办法指定Maven只在给定的-am依赖项既不存在于my-profile中也不存在于.m2本地的情况下构建它?




Regarding the potential duplicate Maven 2: Only build artifact if not already installed in local repository:

关于潜在的重复Maven2:仅构建构件(如果尚未安装在本地存储库中):


In my case I do want to build the projects referenced after the -pl flag regardless of whether they were already built or not. It's the dependencies that are my problem. Also, that question is regarding Maven 2, perhaps things have changed since.

在我的例子中,我确实希望构建在-pl标志之后引用的项目,而不管它们是否已经构建。依赖是我的问题所在。另外,这个问题是关于Maven 2,也许事情从那以后发生了变化。


更多回答

Does this answer your question? Maven 2: Only build artifact if not already installed in local repository

这回答了你的问题吗?Maven 2:如果尚未在本地存储库中安装,则仅生成构件

This post is under discussion at meta.

这篇文章正在Meta讨论中。

Make a post the best self-contained presentation you can. Don't make readers go elsewhere, like another Q&A or version, put everything needed to ask in your post. Clarify via edits, not comments. Delete & flag obsolete comments. If another Q&A is not a duplicate edit your post to make that clear in a self-contained way & again do not require us to go elsewhere. Quote & paraphrase with credit. The suggestion on meta to reference an earlier version is a bad idea. PS Avoid social & meta commentary in posts. PS Yes-or-no questions are seldom useful or asking for what's actually wanted. How to Ask

让帖子成为你能做到的最好的、独立的演示文稿。不要让读者去其他地方,比如另一个问答或版本,把所有需要问的都放在你的帖子里。通过编辑来澄清,而不是通过评论。删除和标记过时的评论。如果另一个问答不是重复的,请编辑你的帖子,以一种独立的方式澄清这一点&同样,不要要求我们去其他地方。引用和释义与信用。关于meta引用较早版本的建议不是一个好主意。PS避免在帖子中发表社交评论和元评论。PS是或否的问题很少有用,也不会问你真正想要的是什么。如何提问

优秀答案推荐

Short answer: Maven as shipped cannot do this. Once you use -am to specify that dependencies should be included in the reactor (or include/exclude them through profiles) there's nothing special about the original -pl list, so this is essentially a duplicate of Maven 2: Only build artifact if not already installed in local repository, which has a similar answer to this one:

简而言之:Maven在发布时不能做到这一点。一旦您使用-am指定应该将依赖项包括在反应器中(或通过配置文件包括/排除它们),原始-pl列表就没有什么特别之处,因此这基本上是Maven2的副本:如果尚未安装在本地存储库中,则只生成构件,这与下面的答案类似:



The short answer is: there's no sane way to do that, Maven doesn't work that way.



You may get better results from use of incremental builds, or from building your own scripting around Maven. You may also be able to make use of profiles to focus on a subset of the project, but there's no existing command-line flag or configuration option to get what you're asking for.

使用增量构建或围绕Maven构建自己的脚本可能会获得更好的结果。您还可以利用配置文件专注于项目的一个子集,但是没有现有的命令行标志或配置选项来获得您所要求的内容。


更多回答

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com