mvn versions:use-releases only find release in .m2 but could not find in repository

559 Views Asked by At

I need to replace my module's parent and dependent modules' snapshot version with release version for the process of release.

First, I run "mvn versions:set -DremoveSnapshot=true versions:commit" to remove my module's snapshot version. It works well.

Next, I run "mvn versions:use-releases -DprocessParent=true versions:commit". It does not do anything. From the output of mvn,

[INFO] artifact com.xxxxx:parent: checking for updates from maven-group
[INFO] artifact com.xxxxx:parent: checking for updates from central

It seems that it checks my repo, "maven-group", but it could not find it? I do have parent release verion in "maven-group", 0.0.3. the snapshot version in my pom is 0.0.3-SNAPSHOT.

However, if I build the release version of my parent in my local machine (the 0.0.3 of parent will be in .m2), this command can update parent module from 0.0.3-SNAPSHOT. Same thing for dependent module. So it looks to me that versions:use-release only only find the release version info in .m2.

Here is my repo in pom. I use nexus repo. maven-group is the entry for release and snapshot repo.

<repository>
    <id>maven-group</id>
    <url>http://192.168.xxx.xxx:8081/repository/maven-group/</url>
</repository>

Do anyone have some ideas? I have tried to add

<id>maven-group</id>
<url>http://192.168.xxx.xx:8081/repository/maven-group/</url>     
<snapshots>
   <enabled>true</enabled>
</snapshots>
<releases>
   <enabled>true</enabled>"
</releases>" 

for maven-group or directly use maven-releases or maven-snapshots repo in pom file. But none of them works.

Any ideas or suggestions? Thank you in advance!

2

There are 2 best solutions below

3
imran On

Use the -U flag; that will force it to check for updates on the remote repository.

E.g.,

mvn -U versions:use-releases -DprocessParent=true versions:commit
0
Peter Roth On

It's a little odd syntax wise, but I found a command that works. This command will update the parent pom version ONLY if it is a SNAPSHOT AND the exact release version is available. This disables incrementing the version itself since I'm using this in a release script and I want developers to change the version, but I don't want developers to have to remove the -SNAPSHOT after a release of the parent pom. That is just busy work and I'm often one of those developers. :)

mvn -DallowMajorUpdates=false -DallowMinorUpdates=false \
   -DallowIncrementalUpdates=false versions:update-parent

See maven versions:update-parent docs for details