在多模块反应器项目的子模块中从命令行运行特定的Maven插件目标 [英] Running a specific Maven plugin goal from the command line in a sub-module of a multi-module reactor project

查看:333
本文介绍了在多模块反应器项目的子模块中从命令行运行特定的Maven插件目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在这里寻找一种通用技术,但让我们举一个具体的例子.我有一个多模块项目,我想从命令行对项目的子模块之一运行exec:java目标.

I'm looking for a general technique here, but let's give a specific example. I have a multi-module project and I'd like to run the exec:java goal from the command-line against one of the sub-modules of my project.

我知道一种方法是,我可以在整个项目上运行mvn install,然后进入子模块目录,从命令行运行exec:java命令,并将工件解析到我的本地存储库.但是,一直运行mvn install变得很乏味.

I know one approach is that I can run mvn install on the whole project and then just go into the sub-module directory, run the exec:java command from the command line, and have artifacts resolved to my local repository. But running mvn install all the time gets pretty tedious.

我真正想要的是对Maven反应器运行exec:java的能力,其中,类路径是从Maven反应器中项目的活动模块构造的.问题是我不确定这是否可能.天真的方法是从项目的根目录运行exec:java目标,但这会尝试对项目中的每个模块(而不是我感兴趣的目标模块)运行插件.

What I'd really like is the ability to run exec:java against the Maven reactor, where the classpath is constructed from the active modules of the project in the Maven reactor. The problem is that I'm not sure this is possible. A naive approach is to run the exec:java goal from the root of the project, but this tries to run the plugin against every module in the project, as opposed to the target module I'm interested in.

有什么主意吗?我知道我的动机示例是exec:java,但是实际上,我想不时地针对我的项目运行许多单一插件目标,而这些目标超出了整个构建生命周期的范围.

Any idea? I know my motivating example was exec:java, but really there are a number of single plugin goals that I'd like to run against my project from time to time outside of the scope of the full build lifecycle.

推荐答案

我有一个多模块项目,我想对我项目的一个子模块从命令行运行exec:java插件.

我并不是说这将适合您的确切用例,但是可以使用-pl, --projects <arg>选项在多模块构建的子集上运行目标:

I'm not saying that this will fit your exact use case but it is possible to run a goal on a subset of a multi-modules build using the -pl, --projects <arg> option:

mvn exec:java -pl my-module

我知道一种方法是我可以在整个项目上运行"mvn install",然后进入子模块目录,从命令行运行exec:java命令,并将工件解析到我的本地存储库

I know one approach is that I can run "mvn install" on the whole project and then just go into the sub-module directory, run the exec:java command from the command line, and have artifacts resolved to my local repository.

依赖关系解析确实是通过本地存储库完成的.

Dependency resolution is indeed done through the local repository.

我真正想要的是对Maven反应器运行exec:java的能力,其中,类路径是从Maven反应器中项目的活动模块构造的.

What I'd really like is the ability to run exec:java against the Maven reactor, where the classpath is constructed from the active modules of the project in the Maven reactor.

这不是反应堆的真正作用.反应堆构建构造模块的定向图,从该图得出适当的构建顺序,并以计算出的顺序针对模块运行目标/阶段.反应堆构建不会构造一些全局"类路径.

That's not really what a reactor build does. A reactor build constructs an oriented graph of the modules, derives an appropriate build order from this graph and runs the goal / phase against the modules in the calculated order. A reactor build doesn't construct some "global" classpath.

一种幼稚的方法是从项目的根目录运行exec:java目标,但这会尝试对项目中的每个模块(而不是我感兴趣的目标模块)运行插件.

A naive approach is to run the exec:java goal from the root of the project, but this tries to run the plugin against every module in the project, as opposed to the target module I'm interested in.

好吧,这是预期的行为.它似乎并不是您真正想要的.

Well, this is the expected behavior. It just doesn't seem to be what you're actually looking for.

有什么主意吗?我知道我的激励性示例是exec:java,但是确实有很多我想不时针对我的项目运行的单一插件目标超出了整个构建生命周期的范围

Any idea? I know my motivating example was exec:java, but really there are a number of single plugin goals that I'd like to run against my project from time to time outside of the scope of the full build lifecycle

反应堆构建确实允许这样做,但是,正如我所写的,您似乎正在寻找与众不同的东西.也许如果您明确您的确切需求,我将能够提供更好的答案.

A reactor build does allow this but, as I wrote, you seem to be looking for something different. Maybe If you clarify your exact need, I would be able to provide a better answer.

这篇关于在多模块反应器项目的子模块中从命令行运行特定的Maven插件目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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