Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable jCenter repository in Gradle

In my Gradle project, I use a custom Maven repository to download the dependencies I need:

buildscript {
    repositories {
        maven {
            url 'https://maven.my-company.com/'
        }
    }
}

allprojects {
    repositories {
        maven {
            url 'https://maven.my-company.com/'
        }
    }
}

I noticed that on our Jenkins, each build takes a couple more minutes to complete than on my computer. With the help of the debug flag (./gradlew --debug --refresh-dependencies clean :app:assembleDebug | grep jcenter), I noticed that each dependency is looked for in jCenter, even though I removed it from the repositories blocks:

[DEBUG] [org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor] Constructing external resource: https://jcenter.bintray.com/com/google/firebase/firebase-iid/maven-metadata.xml

As our Jenkins has no access to external network, those requests timeout and increase the overall build time. Is there something to do to completely disable jCenter (or any other not explicitly defined repositories) repository in Gradle?

like image 356
Gaëtan Avatar asked Nov 14 '25 14:11

Gaëtan


1 Answers

I asked the question on Gradle's GitHub repository (issue 10376). The issue is not directly coming from my Gradle configuration, but a plugin that added the jCenter repository itself.

To find the plugin adding the repository, I created an init.gradle script like so:

allprojects {
    repositories.all {
        if (url.host == 'jcenter.bintray.com') {
            new Throwable('jcenter repository was just added').printStackTrace()
        }
    }
}

And ran ./gradlew --init-script init.gradle help. In the printed stacktrace I could find the plugin causing the issue, in my case at io.realm.gradle.Realm.apply(Realm.groovy:75).

like image 109
Gaëtan Avatar answered Nov 17 '25 08:11

Gaëtan



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!