如何在根目录中通过 cmd 运行 maven 插件而不 运行 在所有模块中安装此插件?

How to run the maven plugin via cmd in the root directory without running this plugin in all modules?

我们有一个插件需要通过cmd 运行,例如:

mvn com.test.plugins:some-plugin:2.1.0:generate

有一个根pom.xml,它有3个模块

<modules>
    <module>first</module>
    <module>second</module>
    <module>third</module>
</modules>

当插件以这种方式从根目录启动时,插件在每个模块中启动 4 次。 我知道如果你在 pom.xml

中编写插件配置
<build><plugins><plugin>

我们可以使用标签

<inherited>false</inherited>

如何通过控制台执行此操作? 或者我们可以在插件的 Mojo class 中添加一些东西?

使用-N(或--non-recursive)命令行参数:

mvn -N com.test.plugins:some-plugin:2.1.0:generate