question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Gradle-versions-plugin's version resolution is interfered by resolutionStrategy

See original GitHub issue

I’m troubleshooting BEAM-8654 where BEAM’s dependency update check does not see newer versions available in Maven Central.

By trimming irrelevant components, I managed to create minimum code to reproduce the problem:

My build.gradle"

plugins {
    id 'java'
    id "com.github.ben-manes.versions" version "0.27.0"
}

group 'suztomo'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    compile "com.google.cloud.bigtable:bigtable-client-core:1.8.0"
}

// This resolutionStrategy is not intended for Gradle versions plugin, but to
// prefer Beam project's recommended versions to Gradle's default reoslution
// algorithm
configurations.compile.resolutionStrategy {
    force(["com.google.cloud.bigtable:bigtable-client-core:1.8.0"])
}

This shows:

> Task :dependencyUpdates

------------------------------------------------------------
: Project Dependency Updates (report to plain text file)
------------------------------------------------------------

The following dependencies are using the latest milestone version:
 - com.github.ben-manes.versions:com.github.ben-manes.versions.gradle.plugin:0.27.0
 - com.google.cloud.bigtable:bigtable-client-core:1.8.0
...

However, com.google.cloud.bigtable:bigtable-client-core has newer version 1.12.1 in Maven Central.

The resolutionStrategy statement is not for Gradle versions plugin. This has been added to Beam’s build.gradle to pick up Beam’s preferred library versions rather than Gradle’s default dependency resolution algorithm(as per the comment in BeamModulePlugin). Unfortunately this resolutionStrategy is interfering Gradle versions plugin and prevents it from reporting the latest versions of its libraries.

Do you know good way to avoid this interference?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ben-manescommented, Nov 14, 2019

Gradle changes quite a bit so maybe that trick doesn’t work anymore.

You can also try gradle.startParameter.taskName,

if (!gradle.startParameter.taskNames.contains('dependencyUpdates')) { ... }
0reactions
calvarez-ovcommented, Jul 29, 2021

I seem to have discovered an issue with this workaround

if (!gradle.startParameter.taskNames.contains('dependencyUpdates')) { ... }

It seems that this causes ben-manes to not know what versions of the project we’re currently using.

I just noticed today, with this scenario:

  • Android gradle plugin 7.0.0, which wants to use jacoco 0.8.3
  • I use a resolutionStrategy to force jacoco 0.8.7. I see this works by running the ./gradlew :module:dependencies task
  • If I run ben-manes, though, it complains that I’m on the old jacoco, presumably because my resolution strategy isn’t applied 🤔 :
    The following dependencies have later release versions:
     - org.jacoco:org.jacoco.ant [0.8.3 -> 0.8.7]
         http://jacoco.org
    

I don’t know if this is an issue specific to the way that android gradle plugin brings in jacoco. Perhaps it’s not the way most library dependencies work…

Read more comments on GitHub >

github_iconTop Results From Across the Web

ResolutionStrategy - Gradle DSL Version 7.6
Defines the strategies around dependency resolution. For example, forcing certain dependency versions, substitutions, conflict resolutions or snapshot ...
Read more >
Manage Gradle version conflicts with resolution strategy
Gradle dependency resolution, conflict types, and how to resolve accidental dependency version upgrades?
Read more >
Why does the version set by useVersion in ... - Stack Overflow
My assumption was the resolutionStrategy of the plugin is able to override every version when the dependency management of the plugin is used....
Read more >
ResolutionStrategy - Gradle DSL Version 2.1
Defines the strategies around dependency resolution. For example, forcing certain dependency versions, conflict resolutions or snapshot timeouts. Examples:
Read more >
resolutionStrategy.force doesn't work as expected
So far we tried to add force resolution block to module's build.gradle: ... At some point it switches dependency version again.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found