我正在使用父POM来定义一个我不想在子POM中运行的插件.如何完全禁用子pom中的插件?
约束:我无法更改父POM本身.
相对较新的开发人员,尽管我已经使用了一段时间,但我希望能够巩固我的Maven基础知识.我的一部分问题是我没有使用Ant的经验,这似乎来自许多解释的起源.我一直在阅读和观看教程,我一直听到相同的条款:
从我所学到的,似乎生命周期是最广泛的,并且由阶段,插件和/或目标组成(或完成).
问题:您能否提供有关这些术语如何相关的任何信息以及最常见的示例?
越明确,越基本越好!
问题
我有一个maven项目,其结构与下面的相似:(
为简化起见而简化)
--parent
|-- child A (inherits from parent)
|-- child B (inherits from parent)
|-- child B1 (inherits from B)
|-- child B2 (inherits from B)
|-- child B3 (inherits from B)
Run Code Online (Sandbox Code Playgroud)
仅仅孩子B1和B2必须使用包含一些额外构建内容的特定配置文件构建.结果,配置文件已在模块B中指定.
逻辑上,模块属于模块B,并且还继承了一些依赖项等(aggreagtion + inheritance).
(想象一下像B = Frontend,B1 = UI,B2 = Themes,B3 = Something)
题
编辑
编辑,因为问题被确定为重复:问题是相应问题中提到的解决方案不起作用.
如果我通过使用属性激活子配置文件,它也将被激活模块B(父级)和所有子级.
我只希望它对孩子B1和B2有效.
我想从命令行执行插件目标,但执行插件的多次执行.为此,我的POM看起来像这样:
<plugin>
<groupId>xxx.yyy</groupId>
<artifactId>zzz</artifactId>
<version>1.1.6</version>
<executions>
<execution>
<id>default-cli-1</id>
<goals>
<goal>mygoal</goal>
</goals>
<configuration>
.... config1 ....
</configuration>
</execution>
<execution>
<id>default-cli-2</id>
<goals>
<goal>mygoal</goal>
</goals>
<configuration>
.... config2 ....
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我想做的是:
mvn xxx.yyy.zzz:mygoal
Run Code Online (Sandbox Code Playgroud)
然后执行两次执行.但我无法弄清楚如何.
我知道<id>从命令行执行时我不能使用.这就是它的意思default-cli.然而,<id>必须是唯一的,<executions>这意味着我只能把它default-cli放在一个execution.
Maven 3.0.5版.
如果我错了,请纠正我。如果 Maven 中没有定义打包类型pom.xml,jar则默认使用生命周期。
每个 Maven 打包类型都有一个默认的构建生命周期和关联的默认目标。(我们可以将目标视为插件+命令)
生命周期阶段目标
我的问题是:
在定义打包类型时,我们是否可以说pom.xml插件部分填充了该打包构建生命周期的默认插件和目标?
另外:
如果我们在插件部分定义一个插件,例如编译器插件,并给出其配置,这些配置是否会覆盖插件默认配置?
<profile>
<id>integration-tests</id>
<activation>
<property>
<name>integrations</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<id>script-chmod</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>chmod</executable>
<arguments>
<argument>+x</argument>
<argument>integration-test-docker/integrations.sh</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>script-exec</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>integration-test-docker/integrations.sh</executable>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Run Code Online (Sandbox Code Playgroud)
此配置文件中包含更多内容,但我只包含了我想要运行的内容.如何执行此特定插件的特定目标?
我试过mvn exec:exec但是我明白了
[错误]无法执行目标org.codehaus.mojo:exec-maven-plugin:1.3.2:exec(default-cli)on project ando:目标org.codehaus.mojo的参数'executable':exec-maven-插件:1.3.2:exec丢失或无效 - > [帮助1]
此外,错误输出表明版本1.3.2,但我正在使用1.4.0.