【发布时间】:2016-06-05 23:27:36
【问题描述】:
我正在将一个插件集成到一个多模块项目中。
我正在使用一个 3rd 方插件,它基本上只需要从父项目运行(基于我对它的理解和使用)。我尝试通过使用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 目标。
如何仅通过激活(如配置文件或其他功能,或仅通过显式运行目标)并仅在父级中运行目标?
【问题讨论】:
标签: maven