2024-04-04 22:38:14 +00:00
## The `setup-gradle` action
2019-09-20 21:06:59 +00:00
2024-04-04 22:38:14 +00:00
The `setup-gradle` action can be used to configure Gradle for optimal execution on any platform supported by GitHub Actions.
2019-09-20 21:06:59 +00:00
2024-04-04 22:38:14 +00:00
This replaces the previous `gradle/gradle-build-action` , which now delegates to this implementation.
2023-08-17 21:13:47 +00:00
2024-04-04 22:38:14 +00:00
The recommended way to execute any Gradle build is with the help of the [Gradle Wrapper ](https://docs.gradle.org/current/userguide/gradle_wrapper.html ), and the examples assume that the Gradle Wrapper has been configured for the project. See [this example ](../docs/setup-gradle.md#build-with-a-specific-gradle-version ) if your project doesn't use the Gradle Wrapper.
2023-08-17 21:13:47 +00:00
2024-04-04 22:38:14 +00:00
### Example usage
2023-08-17 21:13:47 +00:00
2020-06-15 14:23:01 +00:00
```yaml
2024-04-04 22:38:14 +00:00
name: Build
2021-08-17 22:15:28 +00:00
2024-04-04 22:38:14 +00:00
on: [ push ]
2023-07-07 19:42:32 +00:00
jobs:
build:
runs-on: ubuntu-latest
steps:
2024-04-04 22:38:14 +00:00
- name: Checkout sources
uses: actions/checkout@v4
2024-04-05 20:45:05 +00:00
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
2023-08-20 22:27:48 +00:00
- name: Setup Gradle
2024-01-29 16:52:29 +00:00
uses: gradle/actions/setup-gradle@v3
2024-04-04 22:38:14 +00:00
- name: Build with Gradle
2023-08-20 22:27:48 +00:00
run: ./gradlew build
```
2024-04-04 22:38:14 +00:00
See the [full action documentation ](../docs/setup-gradle.md ) for more advanced usage scenarios.