name: Set up Java and the Gradle cache description: >- Installs the repository's pinned Temurin JDK and restores the Gradle cache keyed on this repository's build files. Every Gradle job used to carry this block verbatim, so the JDK patch level and the cache key lived in fifty-nine places and could drift in any one of them. # Deliberately NOT in this action: `actions/checkout` and the Gradle wrapper validation step. # # Neither can move here, and the reasons are different: # # * checkout — a `./.github/actions/...` reference is resolved from the checked-out working # copy, so the action file does not exist until checkout has already run. A composite action # cannot contain the step that makes itself readable. # * wrapper validation — .github/scripts/verify-gradle-wrapper.sh reads each workflow job and # requires it to contain, literally and in this order, an `actions/checkout@` step, the exact # three-field pinned wrapper-validation step, and then the Gradle invocation. That literalness # is the guard: it is what makes "this job validated the wrapper before running it" checkable # from the workflow file alone. Hiding the step behind an action would also break the guarded # `if: ${{ always() && steps.gradle-wrapper-validation.outcome == 'success' }}` form the same # script enforces, because a composite action's step ids are not visible to its caller — the # condition would silently evaluate to false and skip the step it was protecting. # # So a Gradle job is four lines of preamble (checkout, the three-line validation step) plus one # line for this action, instead of thirteen. runs: using: composite steps: - uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # actions/setup-java@v4.7.1 with: distribution: temurin java-version: "21.0.11+10" cache: gradle cache-dependency-path: | src/**/*.gradle src/**/gradle-wrapper.properties src/**/gradle.lockfile