Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Illegal state while comparing versions with latest.release #4684

Open
asibross opened this issue Nov 18, 2024 · 2 comments
Open

Illegal state while comparing versions with latest.release #4684

asibross opened this issue Nov 18, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@asibross
Copy link

This exception was thrown:

Caused by: java.lang.RuntimeException: Error while visiting build.gradle: java.lang.IllegalStateException: Illegal state while comparing versions : [latest.0.0.0.0.0.0] and [3.0.1]. Metadata = [3.0.1]
  org.openrewrite.semver.LatestRelease.compare(LatestRelease.java:164)
  org.openrewrite.semver.VersionComparator.upgrade(VersionComparator.java:45)
  org.openrewrite.gradle.DependencyVersionSelector.select(DependencyVersionSelector.java:142)
  org.openrewrite.gradle.DependencyVersionSelector.select(DependencyVersionSelector.java:83)
  org.openrewrite.gradle.UpgradeDependencyVersion$1.visitMethodInvocation(UpgradeDependencyVersion.java:227)
  org.openrewrite.gradle.UpgradeDependencyVersion$1.visitMethodInvocation(UpgradeDependencyVersion.java:148)

When using a gradle dependency with map notation and latest.release version.
For example:

implementation group: 'com.jayway.jsonpath', name: 'json-path', version: 'latest.release'

When using String notation things work as expected:

implementation 'com.jayway.jsonpath:json-path:latest.release'

What version of OpenRewrite are you using?

rewrite-core version: 8.40.2

How are you running OpenRewrite?

I am using the Gradle init script.

@asibross asibross added the bug Something isn't working label Nov 18, 2024
@timtebeek
Copy link
Contributor

Thanks for the report @asibross ! Indeed seems like we're misinterpreting the version for that particular notation. Would you want to help resolve the issue by opening a draft PR that adds a unit test first? UpgradeDependencyVersionTest.java has a few examples already that should be easy to copy and adjust to match your case.

@timtebeek timtebeek moved this to Backlog in OpenRewrite Nov 19, 2024
@shanman190
Copy link
Contributor

Just to tack on here, but I'm positive that this same thing would happen for latest.integration as well. So the fix is probably just covering those two SemVer types as no upgrade available edge cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

3 participants