Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Gradle Wrapper if specified without Gradle version #427

Closed
wants to merge 3 commits into from
Closed

Use Gradle Wrapper if specified without Gradle version #427

wants to merge 3 commits into from

Conversation

andersfischernielsen
Copy link

@andersfischernielsen andersfischernielsen commented Sep 12, 2022

This will fix the bug described and confirmed in gradle/actions#33.


This will use the available gradlew executable in order to allow post steps to clean up the cache as expected when the wrapper Gradle version is specified for the action.

Signed-off-by: Anders Fischer-Nielsen <andersfischern@me.com>
src/cache-cleaner.ts Outdated Show resolved Hide resolved
Signed-off-by: Anders Fischer-Nielsen <andersfischern@me.com>
Signed-off-by: Anders Fischer-Nielsen <andersfischern@me.com>
@bigdaz
Copy link
Member

bigdaz commented Sep 13, 2022

Thanks for the PR. I'm a bit wary of this solution, since it assumes a Gradle project (with wrapper) is located in the root of the repository. So it wouldn't work for workflows like:

    - name: Setup Gradle
      uses: gradle/gradle-build-action@v2
      with:
        gradle-home-cache-cleanup: true

    - name: Execute Gradle build 1
      run: ./gradlew build
      working-directory: projects/gradle/proj-1

    - name: Execute Gradle build 2
      run: ./gradlew build
      working-directory: projects/gradle/proj-2

There's also the issue that you want a newer version of Gradle to perform the cleanup. Older versions will not properly cleanup the state generated by newer versions.

An alternative solution would be to auto-provision the latest version of Gradle to the PATH whenever gradle-home-cache-cleanup is enabled AND no gradle executable is found on the path.

@andersfischernielsen
Copy link
Author

An alternative solution would be to auto-provision the latest version of Gradle to the PATH whenever gradle-home-cache-cleanup is enabled AND no gradle executable is found on the path.

This sounds like an optimal approach instead of assuming a wrapper project 😄

Given that we've set these in all our uses of the action and that the changes to get this done are nontrivial (especially in an unknown codebase) I'll close the PR.

But thanks for the helpful response! Nice to get an understanding of the behaviour we were seeing 🙏🏼

@andersfischernielsen andersfischernielsen deleted the use-gradle-wrapper-if-selected branch September 20, 2022 07:46
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.

3 participants