Skip to content

./gradlew build is 'Compiling and testing with Java 21' although actions/setup-java@v4 is setting Java 17 #714

@GabeGiro

Description

@GabeGiro

Description:
./gradlew build is 'Compiling and testing with Java 21' after actions/setup-java@v4 is setting Java 17.

I tried a lot of things:

Task version:
v3 and v4

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Repro steps:

Use this ci.yml in your Android project:

name: CI

on:
  pull_request:
    branches:
      - main
      - dev
  push:
    branches:
      - main
      - dev

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4

      - name: Set up JDK 17
        uses: actions/setup-java@v4
        with:
          distribution: 'zulu'
          java-version: '17'

#      - name: Cache Gradle packages
#        uses: actions/cache@v4
#        with:
#          path: |
#            ~/.gradle/caches
#            ~/.gradle/wrapper/
#          key: ${{ runner.os }}-gradle-v1-${{ hashFiles('**/build.gradle', '**/build.gradle.kts', '**/settings.gradle', '**/settings.gradle.kts', '**/gradle.lockfile') }}
#          restore-keys: |
#            ${{ runner.os }}-gradle-v1-

      - name: Grant execute permission for Gradle Wrapper
        run: chmod +x ./gradlew

      - name: Build with Gradle
        run: ./gradlew build

      - name: Run Unit Tests
        run: ./gradlew test

      - name: Notify Success
        if: success()
        run: echo "Build and tests passed!"

      - name: Notify Failure
        if: failure()
        run: echo "Build or tests failed!"

Note: I commented out the cache for the purpose of making sure that I'm not reusing gradle files

Expected behavior:
Build with Gradle step should show:
Compiling and testing with Java 17

Actual behavior:
Build with Gradle step shows:
Compiling and testing with Java 21

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions