mojohaus / versions

Versions Maven Plugin
https://www.mojohaus.org/versions/versions-maven-plugin/
Apache License 2.0
337 stars 269 forks source link

versions:update-properties doesn't update properties to release from snapshot-disabled repos #192

Closed datalogics-kam closed 2 years ago

datalogics-kam commented 7 years ago

Given a settings.xml containing a setup generated by Artifactory:

  <profiles>
    <profile>
      <repositories>
        <repository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>libs-release</name>
          <url>http://artifactory.dlogics.com:8081/artifactory/libs-release</url>
        </repository>
        <repository>
          <snapshots />
          <id>snapshots</id>
          <name>libs-snapshot</name>
          <url>http://artifactory.dlogics.com:8081/artifactory/libs-snapshot</url>
        </repository>

the following command:

$ mvn -V -B -N -X versions:update-properties

says stuff like:

[DEBUG] Skipping update check for artifact com.example:product (/Users/kam/.m2/repository/com/example/product/maven-metadata-central.xml) from disabled repository central (http://artifactory.dlogics.com:8081/artifactory/libs-release)
...
[DEBUG] getNewestVersion(): includeSnapshots='false'
[DEBUG] Property ${product.version}: Set of valid available versions is []
[DEBUG] Property ${product.version}: Restricting results to [4.0.0,5.0.0-!)
[DEBUG] lowerBoundArtifactVersion: 4.9.1-SNAPSHOT
[DEBUG] Property ${product.version}: Current winner is: null
[INFO] Property ${product.version}: Leaving unchanged as 4.9.1-SNAPSHOT

I was expecting it to update the version to 4.10.0, which exists in the libs-release repo.

Basically, when not allowing snapshots, it ignores the repository that can't have snapshots in it.

But if I remove the XML that sets snapshots.disabled to false, it works as expected.

Maybe I'm deeply not understanding something, but shouldn't it be looking in the release repo for a release version number?

datalogics-kam commented 7 years ago

Someone seems to be having a similar problem as mentioned in this Stack Overflow question.

joshar1 commented 7 years ago

@datalogics-kam - I noticed the same problem. While I wasn't able to isolate it in the code base, I was able to figure out that it has something to do with where the property is defined. For instance, if the property is defined in a parent pom, "mvn versions:display-property-updates" will correctly look across all of my repositories for the release versions and thus suggest the latest release over the currently configured snapshot version. If, however, the property is defined inside of the same pom file that declares the dependency, I see the behavior you describe and thus it never examines my release repositories.

ranarula commented 6 years ago

Phew - This is the same issue that baffled me for over a few days. Need to have a fix for this. Had to follow the workaround as mentioned in the Stack Overflow thread to get it to work for now

derylspielman commented 5 years ago

I am too getting this. Any updates?

DidierLoiseau commented 2 years ago

This is unfortunate as I wanted to use update-properties as a workaround for #336

Well I guess I’ll have to allow snapshots for the release repositories then…

foal commented 2 years ago

Please reopen this issue - it is actual.