Newest gradle is run despite using wrapper

Hello,
My gradle.yaml:

# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Java CI with Gradle

on:
  push:
    branches: [ xxx ]
  pull_request:
    branches: [ xxx ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - uses: gradle/wrapper-validation-action@v1
    - name: Set up JDK 1.8
      uses: actions/setup-java@v1
      with:
        java-version: 1.8
    - name: Build with Gradle
      run: gradle wrapper --gradle-version=4.6 --distribution-type=all

yet build fails due to gradle scripts incompability with newest gradle:

Run gradle wrapper --gradle-version=4.6 --distribution-type=all

Welcome to Gradle 6.5.1!

Here are the highlights of this release:
 - Experimental file-system watching
 - Improved version ordering
 - New samples

For more details see https://docs.gradle.org/6.5.1/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)
Configuration on demand is an incubating feature.


FAILURE: Build failed with an exception.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.

Use '--warning-mode all' to show the individual deprecation warnings.
* Where:
See https://docs.gradle.org/6.5.1/userguide/command_line_interface.html#sec:command_line_warnings
Build file '/home/runner/work/xxx/xxx/xxx/build.gradle' line: 18

* What went wrong:
A problem occurred evaluating project ':desktop'.
> Could not get unknown property 'classesDir' for main classes of type org.gradle.api.internal.tasks.DefaultSourceSetOutput.

I am new to whole gradle thing, so perhaps I am doing something wrong?

Hi @jacek-bulatek,

Glad to see you in Github Forum ticket!

When you perform the wrapper task using gradlew, it will still execute with current version (Gradle 6.5.1 ). The arguments only change the values that are written to gradle-wrapper.properties . The gradle-wrapper.jar file is still the one copied from the 6.5.1 distribution. The next build run using gradlew will download the new version distribution and use the new version(version 4.6).

I copied your code and confirmed it on my workflow: https://github.com/weide-zhou/protobuf-gradle-plugin/runs/939173587?check_suite_focus=true#step:6:10

image

Please refer to this link here for more details.

Your error should be due to the deprecated classesDir property, please use getClassesDirs() instead.

Please refer to below link for more details:

Thanks.

Creating and using gradlew helped.