Maven: different configuration for different purposes

I would like to have different configuration options for different purposes of the Maven release plugin. The story is as follows:

I am using Git for SCM. I want a release: prepare a plug-in to do everything locally; and release: run to immediately transfer all changes to a remote repository.

I tried to do something like this:

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> <version>2.2.2</version> <executions> <execution> <id>release-prepare</id> <configuration> <pushChanges>false</pushChanges> </configuration> <goals> <goal>prepare</goal> </goals> </execution> <execution> <id>release-perform</id> <configuration> <localCheckout>true</localCheckout> <pushChanges>true</pushChanges> </configuration> <goals> <goal>perform</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-scm-plugin</artifactId> <version>1.7-SNAPSHOT</version> </dependency> </dependencies> </plugin> 

Version 1.7-SNAPSHOT is required for localCheckout = true to work in general (http://jira.codehaus.org/browse/SCM-662) if anyone is wondering about this.

With the settings mentioned above, all configuration parameters are completely ignored, but when I just specify settings like this:

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> <version>2.2.2</version> <configuration> <localCheckout>true</localCheckout> <pushChanges>false</pushChanges> </configuration> <dependencies> <dependency> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-scm-plugin</artifactId> <version>1.7-SNAPSHOT</version> </dependency> </dependencies> </plugin> 

they apply to both release: prepare and release: complete that is not the desired result.

Edit

To make everything clear: while we use Git for SCM, we would like to have all the operations leading to the preparation of the release location, which is not without reason, given that the local Git repository is a full repo. However, when we do the actual release, we would like all the changes to be transferred to the upstream repository so that everything is installed correctly.

Can anyone help me with this?

+4
source share
2 answers

In case you need to change that you must change the release of the plug-in during the release: execute (the goal!) The release plug-in will check the tagged state of the project and invoke the deployment life cycle on it. So this will not work.

EDIT: I checked this with the Git project and made a release on it, and that, as I explained. During release: prepare the goal, the changes will be transferred to the remote repository. At release time: to fulfill the goal, nothing will be transferred to the remote repository, only the clone will be executed to verify the marked version.

0
source

First I have to say that during the release: to prepare the goal, all changes will be made in SCM, and not in the release: to fulfill the goal. Therefore, the question arises, why do you need to do this in such a complex (non-maven) way?

-one
source

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


All Articles