Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven release properties

When we release projects it is usually the same every time. Are there any arguments or properties that I can add to release:prepare that will allow for pattern releasing in batch mode?

Example:

What is the release version for "MyProject"? (company.jar.site:myproject) 0.0.1: : 
What is SCM release tag or label for "MyProject"? (company.jar.site:myproject) MyProject-0.0.1: : 
What is the new development version for "MyProject"? (company.jar.site:myproject) 0.0.2-SNAPSHOT: : 

It would be nice to do something like this:

mvn -B release:perform -DreleaseVersion:$nextMinorVersion$ or
mvn -B release:perform -DreleaseVersion:$nextPatchVersion$ or
mvn -B release:perform -Dtag:v$nextPatchVersion$ or
mvn -B release:perform -Dtag:v$nextPatchVersion$-someCustomNaming 

If something like this does not already exist, I will create a custom Mojo to do so.

Alternatively, during the prompts above we usually do default to the 1st question, 'v' + current version on the second, and next minor on the last. If we could modify these somehow, that would solve the immediate issue.

Thanks in advance.

like image 536
javamonkey79 Avatar asked Jun 13 '09 00:06

javamonkey79


3 Answers

mvn -B release:prepare release:perform

-B is for batch mode, it will use the defaults it offers when in non-batch mode. Generally for X.Y.Z-SNAPSHOT, it does a release of X.Y.Z and sets the new snapshot to X.Y.(Z+1)-SNAPSHOT.

As with all things maven, you can fight this naming convention and have lots of headaches, or give in and decide your versions and labels are going to be the maven way and get lots for free. I fought it, and lost. Just one of the many ways that you have to give over completely to maven if you're going to use it.

I'm perfectly happy having done so, wanting to impose my own schemes usually isn't a good idea anyway.

like image 75
caskey Avatar answered Sep 22 '22 04:09

caskey


Partial answer, after your comment:

To change the tag name, use the -Dtag=xxx argument to release:prepare. See the release:prepare documentation for details.

Untested code warning

To do this in a fully automated way, you need to add a configuration entry to your pom.xml where you would set the tag name:

<maven-release-plugin>
   <configuration>
       <tag>parent-${releaseVersion}</tag>
   </configuration>
</maven-release-plugin>
like image 22
Robert Munteanu Avatar answered Sep 23 '22 04:09

Robert Munteanu


The way i have done it is Performing a Non-interactive Release Using a properties file.

You create a release.properties in the root of the aggregator project (the one that has packaging:pom) and for each project you add two properties of the following form:

project.rel.<groupId>\:<artifactId>=<releaseVersion>
project.dev.<groupId>\:<artifactId>=<nextSnapshotVersion>

if you want to use a particular literal for your tag you add the following property

scm.tag=<tagLiteral>

The following is an example where both things are done (specify the version of each module and defined the literal to be used to tag in the SCM):

scm.tag=my-project-0.2.1
project.rel.org.monachus.monkeyisland\:my-project=0.2.1
project.dev.org.monachus.monkeyisland\:my-project=0.2.2-SNAPSHOT
project.rel.org.monachus.monkeyisland\:module-a=0.1.1
project.dev.org.monachus.monkeyisland\:module-a=0.1.2-SNAPSHOT
like image 29
Monachus Avatar answered Sep 21 '22 04:09

Monachus