-
Notifications
You must be signed in to change notification settings - Fork 4
Resources Extension
The resources { } block lets you sync a GitHub repository into your project's resource directories at build time. This is useful for keeping shared assets, configuration files, or generated resources in a separate repository.
The plugin registers a processGitHubResources task that runs before processResources. It clones the configured repository (or pulls it if already cloned) into the Gradle home cache, then copies the contents into your project's resource source directory.
github {
resources {
repoUrl = "https://github.com/my-org/my-resources"
branch = "main" // default: "main"
path = "assets" // sub-path within the repo; default: "/" (root)
buildOnly = false // default: false
}
}| Field | Type | Default | Description |
|---|---|---|---|
repoUrl |
String |
null |
Full HTTPS or SSH URL of the resource repository |
branch |
String |
"main" |
Branch to clone/pull |
path |
String |
"/" |
Sub-path within the repository to copy; "/" copies the whole repo |
buildOnly |
boolean |
false |
When true, resources are written to build/resources/ instead of src/main/resources/
|
The same accessToken configured in the github { } block is used for cloning private repositories. SSH private keys are also supported — set accessToken to the key content or a path to the key file.
The cloned repository is stored in ~/.gradle/resources/OWNER-REPO/. Subsequent builds pull only the latest changes rather than re-cloning.
Getting started
Using the plugin
Reference