Skip to content

Resources Extension

Intisy edited this page Apr 24, 2026 · 1 revision

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.

How it works

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.

Configuration

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
    }
}

Fields

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/

Authentication

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.

Caching

The cloned repository is stored in ~/.gradle/resources/OWNER-REPO/. Subsequent builds pull only the latest changes rather than re-cloning.

Clone this wiki locally