【发布时间】:2013-05-28 11:45:09
【问题描述】:
插件版本: 2.0
我正在尝试使用 maven-release-plugin 来设置父 POM 和所有模块的版本。
使用以下父 POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>uk.co.mycompany</groupId>
<artifactId>myProject</artifactId>
<version>latest-SNAPSHOT</version>
<packaging>pom</packaging>
<name>My Project</name>
<modules>
<module>../../subPom1</module>
<module>../../subPom2</module>
<module>../../subPom3</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<phase>clean</phase>
<id>set-release-versions</id>
<configuration>
<developmentVersion>1.1.8</developmentVersion>
<autoVersionSubmodules>true</autoVersionSubmodules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
在运行mvn clean install -DskipTests -Pdeploy 时,完全忽略在清理阶段运行插件的配置,并使用值“latest-SNAPSHOT”进行构建。
我期待它从插件配置中获取值“1.1.8”。
每个子 POM 等价于:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>uk.co.mycompany</groupId>
<artifactId>myProject</artifactId>
<version>latest-SNAPSHOT</version>
<relativePath>../../System/build/parentPom.xml</relativePath>
</parent>
...
</project>
为什么忽略配置?
编辑 #1: 文件系统结构按要求:
/
|- system
| |
| |- build
| |
| |-parentPOM file
|
|- business
| |
| | - childPOM1
| | - childPOM2
|- client
| | - childPOM3
| | - childPOM4
忽略 SSCCE 中的 .../... - 我已经混淆了真实值以概括地描述问题。
编辑#2:我已按照建议将定义移至<pluginManagement>,但问题仍然存在(未使用插件,没有向控制台反馈):
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.0</version>
<configuration>
<developmentVersion>1.1.8</developmentVersion>
<autoVersionSubmodules>true</autoVersionSubmodules>
</configuration>
</plugin>
</plugins>
</pluginManagement>
【问题讨论】:
-
首先您应该将maven-release-plugin 的版本更新为2.4.1 而不是2.0(这真的很旧)。是否可以显示项目的文件夹结构?啊。为什么将 maven-release-plugin 绑定到 clean 阶段?这没有意义?
-
嗨。我认为我应该让它在一开始就运行,所以我将它绑定到“干净”。恐怕我被限制使用 2.0。在我的 Eclipse 环境中,每个项目都是一个单独的文件夹。我应该补充一点,这个构建将 JAR 和 WAR 构造成一个 EAR 罚款 - 只是这个插件没有绑定到任何目标,因此被完全忽略。
-
为此,您应该使用 pluginManagement 来配置您所描述的内容。但是你真的需要更新版本,因为旧版本有错误。每个项目都有一个单独的 Eclipse 项目是可以的。但此外,我看到您使用
parentPoml.xml作为父级和不同级别,看起来不太好。有这样不同层次的关系有充分的理由吗? -
按要求添加结构。除了遗留原因之外,没有充分的理由对其进行布局。这不是我的选择,但是正在解决每个孩子的路径以完成没有错误的构建 - 只是 maven-release-plugin 没有订阅目标并且没有触发。
-
我已按照建议将配置移至 pluginManagement,但问题仍然存在。该插件的文档很糟糕 - 没有给出使用 POM 配置的示例。
标签: maven maven-release-plugin