Skip to content

Configuring Gradle for MKK Systems GitHub Packages

This sets up global Gradle credentials so any mkk-systems repo (backend, common, Android modules) can authenticate against GitHub Packages without hardcoding secrets per-project.

1. Create the PAT

You can reuse your PAT that you used to set up InteliJ as long as it has repo and read:packages

  1. Go to GitHub → Settings → Developer settings → Personal access tokens → Tokens (classic)
  2. Click Generate new token (classic)
  3. Name it something identifiable, e.g. mkk-systems-gradle-jetbrains
  4. Set an expiration (90 days, or your preference — just remember it'll need renewal)
  5. Select these scopes:
  6. repo
  7. read:packages
  8. Generate, then copy the token immediately — GitHub only shows it once

2. Add credentials to global gradle.properties

This file lives outside any project, so it applies to every Gradle build on your machine and never gets committed to git.

Linux

mkdir -p ~/.gradle
nano ~/.gradle/gradle.properties

macOS

mkdir -p ~/.gradle
nano ~/.gradle/gradle.properties

Windows (PowerShell)

New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.gradle"
notepad "$env:USERPROFILE\.gradle\gradle.properties"

Add these two lines (same content on all three OSes):

gpr.user=YOUR_GITHUB_USERNAME
gpr.key=YOUR_PAT_HERE

Save and close.

3. Verify it works

From any mkk-systems project:

./gradlew build --refresh-dependencies

To test the token directly against the registry, bypassing Gradle:

curl -H "Authorization: token YOUR_PAT_HERE" \
  https://maven.pkg.github.com/mkk-systems/mkk-common/xyz/rugman27/mkk/common/v0.1.0/common-v0.1.0.pom
- 200 OK → token is good, artifact exists - 403 Forbidden → token exists but isn't authorized (check SSO authorization, org PAT policy, or scopes) - 404 Not Found → token is fine, but that version was never published

4. IntelliJ IDEA / Android Studio (JetBrains Toolbox)

Use the same PAT for IDE-side GitHub integration:

File → Settings → Version Control → GitHub → Add Account → Log in with Token, paste the same PAT. This covers both git operations and any IDE-side package resolution, so you only manage one token across Maven/Gradle and the IDE.

Notes

  • gradle.properties in ~/.gradle/ is never checked into a repo — this is intentional and is why credentials live here instead of in each project's own gradle.properties.
  • If the PAT expires or is regenerated, only this one file needs updating — every project picks up the new value automatically.
  • Rotate/renew before expiration to avoid a repeat of the 403 debugging loop.