我正在使用 Maven 发布插件,并且正在尝试发布。当我在 master(我使用 Git)时,我的项目(多模块)和我的依赖项(也是多模块)都有 SNAPSHOT 版本。
假设我想从没有使用 SNAPSHOT 的 master 中创建一个标签(跳过创建分支)。
这是我的简化 pom.xml:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>results</artifactId>
<version>1.2-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Results parent module</name>
<modules>
<module>results-web</module>
<module>results-persistence</module>
<module>results-domain</module>
<module>results-logic</module>
<module>results-logic-api</module>
<module>results-ear</module>
<module>results-configuration</module>
<module>results-rules-ejb</module>
<module>results-rules</module>
<module>results-rest</module>
</modules>
<properties>
<dependency1.version>1.2.3-SNAPSHOT</main.version>
<dependency2.version>3.4.5-SNAPSHOT</main.version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<tagNameFormat>@{project.version}</tagNameFormat>
<autoVersionSubmodules>true</autoVersionSubmodules>
<localCheckout>true</localCheckout>
<pushChanges>false</pushChanges>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.my.project</groupId>
<artifactId>dependency1-domain</artifactId>
<version>${dependency1.version}</version>
</dependency>
<dependency>
<groupId>org.my.project</groupId>
<artifactId>dependency1-enumerations</artifactId>
<version>${dependency1.version}</version>
</dependency>
<dependency>
<groupId>org.my.project</groupId>
<artifactId>dependency1-logic</artifactId>
<version>${dependency1.version}</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>org.my.project</groupId>
<artifactId>dependency2-domain</artifactId>
<version>${dependency2.version}</version>
</dependency>
<dependency>
<groupId>org.my.project</groupId>
<artifactId>dependency2-enumerations</artifactId>
<version>${dependency2.version}</version>
</dependency>
<dependency>
<groupId>org.my.project</groupId>
<artifactId>dependency2-logic</artifactId>
<version>${dependency2.version}</version>
<type>ejb</type>
</dependency>
</dependencies>
</dependencyManagement>
如果我做:
mvn release:prepare -Darguments="-dependency1.version=1.2.3.0 -Ddependency2.version=3.4.5.0"
这将创建一个仍然具有 SNAPSHOT 依赖项的分支:
<properties>
<dependency1.version>1.2.3-SNAPSHOT</main.version>
<dependency2.version>3.4.5-SNAPSHOT</main.version>
</properties>
我将如何生成一个标签,上面的部分是:
<properties>
<dependency1.version>1.2.3.0</main.version>
<dependency2.version>3.4.5.0</main.version>
</properties>