在所有子模块中从命令行执行目标

发布于 2025-01-04 22:02:48 字数 338 浏览 3 评论 0 原文

这是来自多模块父 pom 的片段。如何在项目的所有子模块中运行目标?


<modules>
    <module>../utp</module>
    <module>../testdependency</module>
</modules>

当我尝试通过 mvn -am -pl utp help:evaluate -Dexpression=project.artifactId 运行此目标时,我只会获得父 pom 的结果,而不会获得任何结果对于 utp 和最终的依赖项。
如何在项目的所有子模块上运行目标?

this is a snippet from a multi-module parent pom. How can I run a goal in all submodules of the project?


<modules>
    <module>../utp</module>
    <module>../testdependency</module>
</modules>

When I try to run this goal by mvn -am -pl utp help:evaluate -Dexpression=project.artifactId, I'll only get the result for the parent pom, I don't get any result for the utp and eventual dependencies.
How can I run a goal on all submodules of a project?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瀟灑尐姊 2025-01-11 22:02:48

根据 文档,我们可以使用 help:评估 评估一些 Maven 表达式

这以交互方式工作,或者以 artifactexpression 作为参数。如果在项目 pom 上运行,它会报告项目的结果;如果在没有 pom 的情况下运行,它会报告 artifact

它并不意味着提供所有依赖项的工件详细信息。

不确定您的要求是什么...如果是要获取各种依赖项详细信息,您可以尝试 maven 依赖插件,例如 mvn dependency:listmvn dependency:tree。如果要知道依赖项的版本是否是最新的,您可以尝试 versions 中的目标maven 插件,例如 mvn display-dependency-updates

编辑:

>中定义的插件parent pom 的部分仅在声明这些 的模块中运行。在其他模块中,它们不运行。也许 mvn help: effective-pom 可以提供一些信息。

As per the documentation, we could use help:evaluate to evaluate some Maven expressions.

This works in an interactive way or takes artifact and expression as parameter. It reports the result for the project if run on the project pom or the artifact if run without a pom.

It is not meant to give the artifact details for all dependencies.

Not sure what your requirement is... If it is to get the various dependency details, you could try one of the goals of maven dependency plugin, like mvn dependency:list or mvn dependency:tree. If it is to know if the versions of the dependencies are upto date, you could try a goal in versions maven plugin like mvn display-dependency-updates.

Edit:

Plugins which are defined in <pluginManagement> section of parent pom are run only in those modules, where these <plugins> are declared. In other modules, they are not run. Perhaps mvn help:effective-pom can give some info.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文