Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle force dependency version?

I've been trying to figure this out all morning. I have a gradle dependency tree that's pulling in the wrong version:

    > Task :myproj:dependencyInsight
io.fabric8:kubernetes-model:4.1.0 (selected by rule)
   variant "runtime" [
      org.gradle.status = release (not requested)
      Requested attributes not found in the selected variant:
         org.gradle.usage  = java-api
   ]

io.fabric8:kubernetes-model:4.3.0 -> 4.1.0
\--- io.fabric8:kubernetes-client:4.3.0
     \--- compileClasspath

I don't want it to downgrade to 4.1.0, but for the life of me can't get it to stop. Have tried the following with no luck at all:

configurations.all {
    resolutionStrategy {
        force 'io.fabric8:kubernetes-model:4.3.0'
    }
}

///////

dependencies {
    compile ('io.fabric8:kubernetes-client:4.3.0')
    { exclude group: 'io.fabric8', module: 'kubernetes-model', version: '4.1.0' }
}

Anyone know another solution that might help? Thanks

like image 406
Brian Avatar asked Feb 26 '26 18:02

Brian


1 Answers

I am always using this way to force the version in Gradle(6.0.1):

configurations.all {
        
        resolutionStrategy {
            eachDependency { DependencyResolveDetails details ->
                if (details.requested.group == 'redis.clients') {
                    details.useVersion "3.0.1"
                }
                if (details.requested.group == 'com.github.jsqlparser') {
                    details.useVersion "2.1"
                }
                if (details.requested.group == 'com.squareup.okhttp3') {
                    details.useVersion "4.0.0"
                }
                if (details.requested.group == 'com.github.pagehelper' && !details.requested.name.contains('spring-boot')) {
                    
                    details.useVersion("5.1.11")
                }
            }
        }
    }

It works fine, hope this help you.

like image 173
Dolphin Avatar answered Mar 01 '26 09:03

Dolphin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!