2

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!

Ming Wu
  • 87
  • 9

2 Answers2

0

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
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
imran
  • 1
  • 2
  • This does not work for me. I have both the snapshot version and release version of my parent pom in my local `~/.m2/repository`. But it doesn't update. It appears that perhaps the command only uses the project version number for the parent version? I could be misreading this PR that claims to have fixed this exact issue. https://github.com/mojohaus/versions/commit/83db71783d8adf5a1b410f9d609a2ba03e6e49d8 But my parent pom is independent of my repo version numbers (I use a company wide shared parent pom that all my repos share). I assume this is fairly standard behavior though. – Peter Roth Jul 14 '23 at 17:36
  • You should have the release version available in your remote repo. https://www.mojohaus.org/versions/versions-maven-plugin/use-releases-mojo.html – imran Aug 01 '23 at 14:52
  • I also have the release version in my remote repo. My repo is a private repo running Sonatype nexus which is configured via my ~/.m2/settings.xml. But, I couldn't get this command to work for me personally. I certainly could be doing something wrong though. – Peter Roth Aug 02 '23 at 19:36
0

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

Peter Roth
  • 104
  • 8