Skip to content

Rework gradle latest versions#290

Merged
cdsap merged 7 commits intomainfrom
adding_latest_versions
Mar 23, 2026
Merged

Rework gradle latest versions#290
cdsap merged 7 commits intomainfrom
adding_latest_versions

Conversation

@cdsap
Copy link
Copy Markdown
Owner

@cdsap cdsap commented Mar 22, 2026

No description provided.

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 22, 2026

Greptile Summary

This PR replaces the hard-coded Gradle enum with a data-driven data class backed by a supported-gradle-versions.txt resource file, and adds a weekly GitHub Actions workflow + shell script that automatically fetches the latest Gradle versions, regenerates wrapper bundles, and opens a PR — eliminating the need for manual version bumps going forward.

Key changes:

  • Gradle is now a data class with lazy-loaded version list from the classpath resource, maintaining backward compatibility via legacyEnumName and the multi-key supportedLookup map.
  • Gradle.latest() / Gradle.oldest() replace previously hard-coded enum constants throughout the codebase.
  • New scripts/update_gradle_versions.sh automates version selection, wrapper bundle generation, stale-bundle pruning, and README update.
  • New .github/workflows/update-gradle-versions.yml runs the script on a weekly Monday schedule and opens a PR with the results.
  • New SupportedGradleVersionsE2ETest parameterises the E2E build test over all supported versions, ensuring regressions are caught automatically.
  • The test name "supported gradle list is capped to five entries" contradicts the actual assertion of 6; the name should be updated.
  • prune_removed_bundles in the shell script uses =~ with an unescaped $base filename as a regex pattern, causing the . in .zip to act as a wildcard rather than a literal character — this is technically incorrect but poses negligible practical risk given the controlled filename namespace.
  • An unused selected = [] variable is present in the Python snippet inside fetch_versions.

Confidence Score: 4/5

  • Safe to merge; the architectural change is clean and well-tested, with only minor issues in the shell script and a stale test name.
  • The core Kotlin refactoring from enum to data class is solid, backward-compatible, and covered by both unit and E2E tests. The two issues in the shell script (unescaped regex in prune_removed_bundles and a dead selected variable) are low-risk. The test name mismatch is cosmetic but should be fixed to avoid confusion.
  • scripts/update_gradle_versions.sh — regex escaping bug in prune_removed_bundles and unused variable in fetch_versions.

Important Files Changed

Filename Overview
project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/model/Gradle.kt Replaces the hard-coded Gradle enum with a data class that loads supported versions lazily from a bundled resource file, enabling fully data-driven version management without code changes.
scripts/update_gradle_versions.sh New automation script that fetches the latest Gradle versions from the official feed, generates wrapper bundles, prunes stale ones, and updates the README — contains an unescaped regex special character in prune_removed_bundles and an unused selected variable in the Python snippet.
.github/workflows/update-gradle-versions.yml New weekly scheduled workflow that runs the update script, executes tests, and opens a PR via peter-evans/create-pull-request@v7 — straightforward and scoped permissions look correct.
project-generator/src/test/kotlin/io/github/cdsap/projectgenerator/model/GradleTest.kt New unit tests for the Gradle data class; logic is correct but the test name "capped to five entries" contradicts the actual assertion of 6.
project-generator/src/test/kotlin/io/github/cdsap/projectgenerator/SupportedGradleVersionsE2ETest.kt New parameterised E2E test that generates and builds a JVM project for every supported Gradle version, providing good coverage of the new data-driven version list.
project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/writer/GradleWrapper.kt Minimal change: replaced the old gradle.name.lowercase() + ".zip" (enum-based) with gradle.resourceZipName (property on data class) — correct and consistent.
project-generator/src/main/resources/supported-gradle-versions.txt New resource file listing the 6 currently supported Gradle versions (3 per major line for 8.x and 9.x); serves as the single source of truth read by Gradle.supportedVersions.
project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/ProjectGenerator.kt One-line change: default gradle parameter updated from the hard-coded Gradle.GRADLE_9_4_0 to the data-driven Gradle.latest() — correctly picks up new versions without code changes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Weekly Schedule / workflow_dispatch] --> B[update_gradle_versions.sh]
    B --> C[fetch_versions\nGET services.gradle.org/versions/all]
    C --> D{Parse JSON\n3 minor lines per major\nfor Gradle 8 and 9}
    D --> E[Write supported-gradle-versions.txt]
    E --> F[generate_wrapper_bundle for each version]
    F --> G[Run gradlew wrapper with version flag]
    G --> H[Zip wrapper files into gradle_X_Y_Z.zip resource]
    H --> I[prune_removed_bundles - delete stale zip resources]
    I --> J[update_readme - Replace version list in README]
    J --> K[Run tests via Gradle]
    K --> L[Open PR with peter-evans/create-pull-request]

    subgraph Runtime - Gradle data class
        M[Gradle.supported] --> N[Load supported-gradle-versions.txt\nfrom classpath - lazy]
        N --> O[Build supportedLookup map\nversion + cliValue + legacyEnumName]
        O --> P[latest / oldest / fromValue]
    end
Loading

Reviews (1): Last reviewed commit: "Rework gradle latest versions" | Re-trigger Greptile

cdsap and others added 6 commits March 22, 2026 18:26
…ator/model/GradleTest.kt

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@cdsap cdsap merged commit 28805b6 into main Mar 23, 2026
12 checks passed
@cdsap cdsap deleted the adding_latest_versions branch March 23, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant