ben-manes / gradle-versions-plugin

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

Latest version v0.43.0 doesn't produce html report #703

Closed gkurmaev closed 1 year ago

gkurmaev commented 1 year ago

After update yesterday our task, which is configured the following way:

tasks.named<DependencyUpdatesTask>("dependencyUpdates").configure {

  // Example 1: reject all non stable versions
  rejectVersionIf {
    isNonStable(candidate.version)
  }

  // optional parameters
  checkConstraints = true
  checkForGradleUpdate = true
  outputFormatter = "json, html"
  outputDir = "build/dependencyUpdates"
  reportfileName = "report"
}

is no longer generating json and html reports (but a json and txt instead), which we uploaded somewhere else as a part of CI-pipeline, thus breaking it.

gkurmaev commented 1 year ago

Removing the extra space after the comma actually fixed the issue, so

outputFormatter = "json,html"
ben-manes commented 1 year ago

Looks like a small typo in the groovy to kotlin migration. The groovy code used String's replaceAll which takes a regex, whereas the kotlin version uses replace which does not.

https://github.com/ben-manes/gradle-versions-plugin/blob/b53e44f1459e7950706e77007b916ee522684baf/src/main/groovy/com/github/benmanes/gradle/versions/updates/DependencyUpdatesReporter.groovy#L127

https://github.com/ben-manes/gradle-versions-plugin/blob/cc714f8154839b1a78fa02425cdac30cc8195e1d/gradle-versions-plugin/src/main/kotlin/com/github/benmanes/gradle/versions/updates/DependencyUpdatesReporter.kt#L112

ben-manes commented 1 year ago

hmm.. seems that kotlin's replace is the same as Java's replaceAll, so I'm not sure why it wouldn't take.

ben-manes commented 1 year ago

Oh, they have multiple variants overloaded with the same name and different behavior. Very confusing stdlib, but I think we can use a trim() here. Seems kotlin has many footguns, like their infamous non-atomic operations on atomics...

It should have been formatterOriginal.replace(Regex("\\s"), ""), but did a string replacement instead.

gkurmaev commented 1 year ago

Oh wow, that was rather unexpected of you to actually fix a closed issue, thanks!