Skip to content

Instantly share code, notes, and snippets.

@sorianog
Created January 13, 2022 16:29
Show Gist options
  • Save sorianog/0c272c75c1cfd9865162a1db74ebb95c to your computer and use it in GitHub Desktop.
Save sorianog/0c272c75c1cfd9865162a1db74ebb95c to your computer and use it in GitHub Desktop.
// Source https://blog.gradle.org/jcenter-shutdown
// In app/module gradle file, do the following
...
repositories {
mavenCentral()
jcenter {
content {
// org.jetbrains.trove4j is only available in JCenter
includeGroup("org.jetbrains.trove4j")
}
}
}
...
/*
* Backstory:
*
* At this point, if the package is only available on JCenter, your options are to:
* Wait for the maintainer to migrate to another repository (e.g., Maven Central)
* Find another equivalent package that is available on Maven Central
* Remove your dependency on the package entirely
* Copy the package to your own internal repository
* If your build can resolve most of its dependencies from another repository, you could continue to use JCenter for the few packages that are only available there. You can prevent new packages that are only available on JCenter from being introduced into your build, by using a content filter. This prevents Gradle from looking in JCenter for all packages.
*
* For instance, many Android projects depend on the Trove4J library that at the time of writing is only available from JCenter. We can use a content filter to only allow artifacts in the org.jetbrains.trove4j group to come from JCenter. We also put jcenter() last so that Maven Central is searched first.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment