gradle-versions-plugin: Breaking change in 0.23.0?

I’ve just picked up the new version of your library and we now get the following error when running useLatestVersions:

Could not set unknown property 'resolutionStrategy' for task ':dependencyUpdates' of type com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask.

If we change our gradle config from dependencyUpdates.resolutionStrategy to dependencyUpdates.resolutionStrategyAction things work as before.

Just wondering if this was an intentional change or not before we roll this fix out across our projects?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Released version 0.24.

The direct assignment of the dependencyUpdates.resolutionStrategy property is supported again, but will issue a deprecation warning. Instead of an explicit =, prefer the DSL style of an assignment method.

// old style
dependencyUpdates.resolutionStrategy = { ... }
// proper style
dependencyUpdates.resolutionStrategy { ... }

This deprecated usage will show up as a build warning like other Gradle feature deprecations, where a detailed message is shown when running with --warning-mode=all.

Sorry, this was unintentional. I’ll have a fix out by the end of the weekend.

cc @ghus-raba

@johnjohndoe BTW both rules -> and ComponentSelection selection -> should not be necessary anymore, as the closures should have proper delegates set. So even this should be ok:

dependencyUpdates.resolutionStrategy {
  componentSelection {
    all {
      def isNonStable = { String version -> 
        ['alpha', 'beta', 'rc', 'cr', 'm', 'preview', 'b', 'ea'].any { qualifier ->
          version ==~ /(?i).*[.-]$qualifier[.\d-+]*/
        }
      }

      if (isNonStable(candidate.version) && !isNonStable(currentVersion)) {
        reject('Release candidate')
      }
    }
  }
}

In regards to the configuration resolution failures, that seems to be an Android / Gradle bug. See #326 - they don’t the handle detached configurations, e.g. like ours created by Configuration.copy(). You would need to ask those teams to resolve their oversight.

I think the change from Closure to Action is compatible enough if the types are inferred by the build scripts. If the 99% case works and one plugin integration has to revise, then I think it’s a fine break. If it leaks into the general case then a little adapter code can probably be done at the task prior to the Resolver (e.g. adapt from the Closure to Action before going downstream).