Maven Release Plugin: Create SNAPSHOT Tag Without Change

I am using the Maven release plugin and I am trying to make a release. When I am on the host (I use Git), I have SNAPSHOT versions for my project (multimodule), as well as for my dependencies (also multimodules).

Suppose I want to make a tag from master (skipping branch creation) where SNAPSHOT is not used.

This is my simplified 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> 

If I do this:

mvn release: prepare -Darguments = "- dependency1.version = 1.2.3.0 -Ddependency2.version = 3.4.5.0"

This creates a branch that still has SNAPSHOT dependencies:

 <properties> <dependency1.version>1.2.3-SNAPSHOT</main.version> <dependency2.version>3.4.5-SNAPSHOT</main.version> </properties> 

How would I generate a tag where the above part would be:

 <properties> <dependency1.version>1.2.3.0</main.version> <dependency2.version>3.4.5.0</main.version> </properties> 
+4
source share
2 answers

The release plugin cannot change dependency versions in the POM that are not part of the reactor.

Try the Maven Version Plugin . You can use versions: use releases to replace all snapshot dependencies with the corresponding releases. If you want to replace them manually (perhaps because the versions are different from the snapshots), you can use the: set versions. But both of them do not work with the dependency versions specified in the properties. For version properties : the update properties are used with the allowSnapshots = false parameter. This target works automatically if special version ranges are not required, but it can also be configured to address such requirements.

You can configure the release plugin to invoke the version plugin using prepareaionGoals , as Stephen said: <preparationGoals>clean versions:use-releases verify</preparationGoals>

Or you call the version plugin manually before release, for example. with

mvn versions: use scm releases: checkin -Dmessage = "Unlock dependency versions"

+3
source

The release plugin is not intended to solve this problem.

You might be able to get somewhere by grabbing preparationGoals and completionGoals to trigger plugins that edit your pom ... Of course, that was the use case I had in mind when I added completionGoals

But for now, in the absence of the ability to get a plugin for editing and unedit your pom to install versions, you will have to live with manual editing

0
source

Source: https://habr.com/ru/post/1484820/


All Articles