Add SBT in cache managers.

This commit is contained in:
Florian Meriaux 2022-03-24 10:11:05 +01:00 committed by GitHub
parent f69f00b5e5
commit 754319f3bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 7 deletions

View file

@ -25,7 +25,7 @@ Inputs `java-version` and `distribution` are mandatory. See [Supported distribut
**Eclipse Temurin**
```yaml
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-java@v2
with:
distribution: 'temurin' # See 'Supported distributions' for available options
@ -36,7 +36,7 @@ steps:
**Zulu OpenJDK**
```yaml
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-java@v2
with:
distribution: 'zulu' # See 'Supported distributions' for available options
@ -69,13 +69,14 @@ Currently, the following distributions are supported:
The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under hood for caching dependencies but requires less configuration settings. Supported package managers are gradle and maven. The format of the used cache key is `setup-java-${{ platform }}-${{ packageManager }}-${{ fileHash }}`, where the hash is based on the following files:
- gradle: `**/*.gradle*`, `**/gradle-wrapper.properties`
- maven: `**/pom.xml`
- sbt: `**/build.sbt`
The cache input is optional, and caching is turned off by default.
#### Caching gradle dependencies
```yaml
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-java@v2
with:
distribution: 'temurin'
@ -87,7 +88,7 @@ steps:
#### Caching maven dependencies
```yaml
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-java@v2
with:
distribution: 'temurin'
@ -97,6 +98,19 @@ steps:
run: mvn -B package --file pom.xml
```
#### Caching sbt dependencies
```yaml
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
cache: 'sbt'
- name: Build with SBT
run: sbt package
```
### Check latest
In the basic examples above, the `check-latest` flag defaults to `false`. When set to `false`, the action tries to first resolve a version of Java from the local tool cache on the runner. If unable to find a specific version in the cache, the action will download a version of Java. Use the default or set `check-latest` to `false` if you prefer a faster more consistent setup experience that prioritizes trying to use the cached versions at the expense of newer versions sometimes being available for download.
@ -107,7 +121,7 @@ For Java distributions that are not cached on Hosted images, `check-latest` alwa
```yaml
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-java@v2
with:
distribution: 'adopt'
@ -126,7 +140,7 @@ jobs:
java: [ '8', '11', '13', '15' ]
name: Java ${{ matrix.Java }} sample
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup java
uses: actions/setup-java@v2
with: