Packagist + Gradle
Setup accelerated dependency downloads for Gradle
Packagist can accelerate both Maven and Gradle Plugin Portal downloads during your Gradle builds. To set things up, proceed via one of the routes below. We recommend using both approaches for ideal cache hit-rates; you should use per-user settings on your machine and per-project settings to setup your CI/CD flows.
Gradle Plugins
Gradle plugin downloads can be accelerated through Packagist. Add the following to your settings.gradle[.kts]
file:
pluginManagement {
repositories {
maven("https://gradle.pkg.st/")
}
}
pluginManagement {
repositories {
maven {
url = uri("https://gradle.pkg.st/")
}
}
}
Maven Central
Maven Central downloads can be accelerated through Packagist. Add the following per-user or per-project settings to get started.
Per-user settings
Setting up Packagist for user-level use involves a Gradle Init script placed in the Gradle User Home. From here, you can easily specify a replacement for your default Maven Central repository:
val pkgst = true // easy killswitch to turn pkgst off if you want
if (pkgst) allprojects {
repositories {
maven("https://maven.pkg.st/")
}
}
def pkgst = true // easy killswitch to turn pkgst off if you want
if (pkgst) allprojects {
repositories {
maven {
url = uri("https://maven.pkg.st/")
}
}
}
Per-project settings
There are several ways to declare repositories in a Gradle build. See below for different options:
In your settings
Setting the Packagist repos in your Gradle Settings is the easiest way to set it up:
dependencyResolutionManagement {
// optional: prefer settings-declared repositories
repositoriesMode = RepositoriesMode.PREFER_SETTINGS
repositories {
maven("https://maven.pkg.st/")
}
}
dependencyResolutionManagement {
// optional: prefer settings-declared repositories
repositoriesMode = RepositoriesMode.PREFER_SETTINGS
repositories {
maven {
url = uri("https://maven.pkg.st/")
}
}
}
In a project
Setting the Packagist repos can also be done on a per-project basis:
repositories {
maven("https://maven.pkg.st/")
}
repositories {
maven {
url = uri("https://maven.pkg.st/")
}
}
Updated about 1 year ago