Agent Skills: Gradle Standards

>

buildID: bitsoex/bitso-java/gradle-standards

Install this agent skill to your local

pnpm dlx add-skill https://github.com/bitsoex/bitso-java/tree/HEAD/.claude/skills/gradle-standards

Skill Files

Browse the full folder contents for gradle-standards.

Download Skill

Loading file tree…

.claude/skills/gradle-standards/SKILL.md

Skill Metadata

Name
gradle-standards
Description
>

Gradle Standards

Standards for Gradle configuration in Java projects, including version catalogs, dependency bundles, and multi-module setup.

When to use this skill

  • Setting up a new Gradle project
  • Adding or updating dependencies
  • Configuring multi-module builds
  • Troubleshooting dependency conflicts
  • Migrating to version catalogs
  • Cleaning up unused dependencies
  • Optimizing build performance
  • When asked for "gradle dependencies cleanup"

Skill Contents

Sections

Available Resources

πŸ“š references/ - Detailed documentation


Quick Start

1. Version Centralization (Required)

All versions MUST be centralized in gradle/libs.versions.toml:

[versions]
spring-boot = "3.5.9"
grpc = "1.78.0"

[libraries]
spring-boot-starter-web = { module = "org.springframework.boot:spring-boot-starter-web", version.ref = "spring-boot" }
spring-boot-starter-actuator = { module = "org.springframework.boot:spring-boot-starter-actuator", version.ref = "spring-boot" }

2. Use in build.gradle

dependencies {
    // βœ… CORRECT: Use version catalog with explicit dependencies
    implementation libs.spring.boot.starter.web
    implementation libs.spring.boot.starter.actuator

    // ❌ NEVER: Hardcode versions
    // implementation "org.springframework.boot:spring-boot-starter-web:3.5.9"
}

Key Principles

| Principle | Description | |-----------|-------------| | Centralize Versions | All versions in libs.versions.toml, never inline | | Explicit Dependencies | Declare each dependency explicitly for clarity | | Use Native Locking | Use Gradle's native dependency locking (Gradle 9+ recommended) | | Never Downgrade | Don't replace existing versions with older ones | | Use platform() for BOMs | Import BOMs via platform(), never enforcedPlatform() or mavenBom directives | | Catalog First | All versions should come from the version catalog; use resolutionStrategy.force only as a last resort for security | | Lock Dependencies | Generate gradle.lockfile for ALL submodules (use custom resolveAndLockAll task with --write-locks; see native-dependency-locking.md for task definition) |

Version Conflicts

All projects should preferably use the versions defined in the version catalog. When the resolved version doesn't match the catalog for some reason, prefer fixing the root cause:

  1. First: Define the correct version in the version catalog and declare the dependency explicitly
  2. Second: Use platform() to import a BOM that manages the version (e.g., Spring Boot dependencies)
  3. Last resort: Use resolutionStrategy.force only for security-critical overrides where the above approaches don't work
// AVOID unless absolutely necessary for security
configurations.configureEach {
    resolutionStrategy {
        // Only for security-critical overrides as a last resort
        force libs.commons.compress  // CVE fix not yet in BOM
    }
}

References

| Reference | Description | |-----------|-------------| | references/version-catalogs.md | Complete version catalog guide | | references/multi-module.md | Multi-module project setup | | references/native-dependency-locking.md | Gradle native locking (Gradle 9+ recommended) | | references/cleanup-workflow.md | Dependency cleanup process | | references/unused-detection.md | Finding unused dependencies | | references/optimization.md | Build optimization techniques | | references/troubleshooting.md | Common issues and solutions |

Related Rules

Dependency Resolution Stack

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  1. VERSION CATALOG (libs.versions.toml)                            β”‚
β”‚     Single source of truth for declared versions                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  2. RESOLUTION STRATEGY (build.gradle)                              β”‚
β”‚     Use Gradle's native resolutionStrategy for:                     β”‚
β”‚     - force() for security fixes                                    β”‚
β”‚     - eachDependency for group alignment                            β”‚
β”‚     - dependencySubstitution for module replacement                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  3. LOCK FILE (gradle.lockfile)                                     β”‚
β”‚     Native Gradle locking (Gradle 9+ recommended)                   β”‚
β”‚     Captures EXACT resolved versions                                β”‚
β”‚                                                                     β”‚
β”‚  ⚠️  CRITICAL: Multi-module projects need lockfiles for ALL modules β”‚
β”‚     Use: ./gradlew resolveAndLockAll --write-locks                  β”‚
β”‚     NOT: ./gradlew dependencies --write-locks (root only!)          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Lock File:

Multi-Module Lockfile Generation:

# βœ… CORRECT: Generates lockfiles for ALL submodules
./gradlew resolveAndLockAll --write-locks --refresh-dependencies --no-daemon --no-scan

# ❌ WRONG: Only generates for ROOT project
./gradlew dependencies --write-locks

# Verify coverage (lockfiles should β‰ˆ build.gradle files)
find . -name "gradle.lockfile" | wc -l
find . -name "build.gradle" | wc -l

Related Skills

| Skill | Purpose | |-------|---------| | dependency-management | Version catalogs and BOMs | | dependabot-security | Security vulnerability fixes | | java-coverage | JaCoCo configuration in Gradle | | java-testing | Test configuration with Spock |

<!-- AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY --> <!-- Source: bitsoex/ai-code-instructions β†’ java/skills/gradle-standards/SKILL.md --> <!-- To modify, edit the source file and run the distribution workflow -->
Gradle Standards Skill | Agent Skills