Kev*_*dge 8 maven-2 maven maven-release-plugin
我有一个多模块maven构建,其中一个子模块需要额外的目标作为发布的一部分执行.但看起来似乎忽略了子模块中maven-release-plugin的任何配置,而支持父模块中的默认配置.
这是子模块的片段.插件配置在父pom的pluginManagement部分中是相同的,但没有自定义元素.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.1</version>
<configuration>
<tagBase>http://mycompany.com/svn/repos/myproject/tags</tagBase>
<goals>deploy myCustomPlugin:myCustomGoal</goals>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
那么子模块是否可以覆盖父模块的配置并添加额外的目标?
Maven版本2.2.1
Pra*_*ate 11
使用 combine.children="append" combine.self="override"
家长POM
<configuration>
<items>
<item>parent-1</item>
<item>parent-2</item>
</items>
<properties>
<parentKey>parent</parentKey>
</properties>
</configuration>
Run Code Online (Sandbox Code Playgroud)
孩子pom
<configuration>
<items combine.children="append">
<!-- combine.children="merge" is the default -->
<item>child-1</item>
</items>
<properties combine.self="override">
<!-- combine.self="merge" is the default -->
<childKey>child</childKey>
</properties>
</configuration>
Run Code Online (Sandbox Code Playgroud)
结果
<configuration>
<items combine.children="append">
<item>parent-1</item>
<item>parent-2</item>
<item>child-1</item>
</items>
<properties combine.self="override">
<childKey>child</childKey>
</properties>
</configuration>
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅此博客
是和不是。当然,子 pom 可以覆盖其父级指定的插件的配置,并且我必须假设您已经正确执行了此操作,因为这没有什么难的。如果您检查 的输出mvn help:effective-pom,您应该能够清楚地看到该模块对发布插件有不同的设置。
您遇到的问题与发布插件的行为有关。通常,如果您mvn compile从项目的根模块运行一个目标或阶段,它首先在根模块上运行该目标/阶段,然后按反应器顺序在所有模块上运行,几乎就像您“ d 自己在每个模块中运行它。您添加到子模块的任何自定义都会按预期生效。当您运行发布插件时,它仅在根模块中运行。它不在任何子模块中运行。相反,在根模块上运行它会使用与根模块相同的设置来创建一个新的构建,该构建以几乎相同的方式为所有其他模块运行,只是它对所有模块使用根模块的配置。我不知道确切的语义,但我相信这类似于您在每个子模块中手动运行发布目标并在命令行将配置选项指定为系统属性:无论子模块如何配置发布插件,命令行参数获胜。
我自己从未处理过这个问题,如果不确切知道你想要完成什么,就很难说。也许如果您可以将您想要在这个特殊模块中执行的操作表达为配置文件,那么您可以将配置文件添加到您的goalsand 或preparationGoals. 或者,还有一个arguments选项可以同时准备和执行目标,您可以使用一些技巧。
| 归档时间: |
|
| 查看次数: |
7446 次 |
| 最近记录: |