我正在将插件集成到多模块项目中。仅通过激活在父POM中运行Maven目标
我使用的第三方插件基本上只需要通过从父项目运行(基于我的理解和使用它)。我试图通过使用profile做到这一点,就像这样:
<profiles>
<profile>
<id>run-my-guy</id>
<build>
<plugins>
<plugin>
<groupId>com.myproject</groupId>
<artifactId>myproject-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>runThing</goal>
</goals>
<inherited>false</inherited>
</execution>
</executions>
<inherited>false</inherited>
</plugin>
</plugins>
</build>
</profile>
</profiles>
我有几个<inherited>false</inherited>
,但如果我跑mvn help:all-profiles
我仍然可以看到每一个模块在此配置文件。如果我运行我的mvn package -P run-my-guy
,我看到这会在每个子项目中执行。我希望能够激活此功能,并且我不希望它在默认情况下处于启用状态。
如果我试图将其添加到<build>
部分,像这样:
<build>
<plugins>
<plugin>
<groupId>com.myproject</groupId>
<artifactId>myproject-maven-plugin</artifactId>
<inherited>false</inherited>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>runThing</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
在这里,我也有一些<inherited>false</inherited>
,只是为了尝试和执行的插件和执行不继承。但是,如果我运行package
阶段或包含该阶段的任何项目,则会包含runThing
目标。
如何仅通过激活(如配置文件或某些其他功能,或者仅通过明确运行目标)来运行目标,并且仅在父级中运行?