ben-manes / gradle-versions-plugin

Gradle plugin to discover dependency updates
Apache License 2.0
3.86k stars 199 forks source link

Incorrect exceeded version reported in HTML report, while correct version is reported in console output #811

Closed jayasuryat closed 1 year ago

jayasuryat commented 1 year ago

Hi @ben-manes, Thanks for this awesome plugin.

I recently encountered this issue, where while reporting exceeded versions, the plugin correctly reports the Latest version in the console output, but in the HTML report the Current version is being reported as the Latest version.


I did some quick digging in the source code, and found this : https://github.com/ben-manes/gradle-versions-plugin/blob/bb9be6edbee2d2e7427b96685b2ae0a7f1d8fa76/gradle-versions-plugin/src/main/kotlin/com/github/benmanes/gradle/versions/reporter/HtmlReporter.kt#L335-L344

Looks like the same value dependency.version is being printed for both Current version & Latest version (instead of dependency.latest (I'm assuming)).

While I assumed that this issue is valid and the thing I found is the cause, I could be wrong. I got a bit curious and did some quick digging.

ben-manes commented 1 year ago

It might have been a mistake from the Groovy rewrite to Kotlin. You might look at the original Groovy code to confirm. PRs are always welcome

jayasuryat commented 1 year ago

Looks like this also existed in the groovy version: https://github.com/ben-manes/gradle-versions-plugin/blob/b53e44f1459e7950706e77007b916ee522684baf/src/main/groovy/com/github/benmanes/gradle/versions/reporter/HtmlReporter.groovy#L169-L172


While the PlainTextReporter seems to be correct in the both versions

PlainTextReporter - Kotlin https://github.com/ben-manes/gradle-versions-plugin/blob/bb9be6edbee2d2e7427b96685b2ae0a7f1d8fa76/gradle-versions-plugin/src/main/kotlin/com/github/benmanes/gradle/versions/reporter/PlainTextReporter.kt#L70-L71

PlainTextReporter - Groovy https://github.com/ben-manes/gradle-versions-plugin/blob/b53e44f1459e7950706e77007b916ee522684baf/src/main/groovy/com/github/benmanes/gradle/versions/reporter/PlainTextReporter.groovy#L127-L128


Thanks for the quick response @ben-manes, I'd love to contribute the fix for this. Let me know if my understanding of the existence of the issue sounds right to you.

ben-manes commented 1 year ago

Yep, it looks like it was maybe changed in #508 where that method used to use the "available version" but had a refactoring mistake. In the original contribution it called item.getLatest().

jayasuryat commented 1 year ago

@ben-manes I've created a PR with the change, the said change only changes the dependency.version to dependency.latest.

I didn't find any tests that needed to be updated, altho some tests are failing only in the DifferentGradleVersionsSpec class, (rest all test classes are passing fine). From what I could understand these were due to Java version mismatch.

Let me know if there is anything else needed to be updated.

ben-manes commented 1 year ago

The tests pass on CI, so I think you're fine too.

I tried it locally by bumping the version, running publishToMavenLocal, and checking the report generated by examples/groovy (which sources the latest from mavenLocal if available). It looked perfect to me.

Screen Shot 2023-09-17 at 9 49 36 AM
jayasuryat commented 1 year ago

Glad to know that everything is working as expected.

This was super quick, thanks @ben-manes.