mirror of
https://github.com/actions/setup-java.git
synced 2025-04-20 09:56:46 +00:00
Add SBT in cache managers.
This commit is contained in:
parent
f69f00b5e5
commit
754319f3bb
2 changed files with 27 additions and 7 deletions
26
README.md
26
README.md
|
@ -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:
|
||||
|
|
|
@ -13,7 +13,7 @@ const CACHE_MATCHED_KEY = 'cache-matched-key';
|
|||
const CACHE_KEY_PREFIX = 'setup-java';
|
||||
|
||||
interface PackageManager {
|
||||
id: 'maven' | 'gradle';
|
||||
id: 'maven' | 'gradle' | 'sbt';
|
||||
/**
|
||||
* Paths of the file that specify the files to cache.
|
||||
*/
|
||||
|
@ -32,6 +32,12 @@ const supportedPackageManager: PackageManager[] = [
|
|||
path: [join(os.homedir(), '.gradle', 'caches'), join(os.homedir(), '.gradle', 'wrapper')],
|
||||
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---gradle
|
||||
pattern: ['**/*.gradle*', '**/gradle-wrapper.properties']
|
||||
},
|
||||
{
|
||||
id: 'sbt',
|
||||
path: [join(os.homedir(), '.ivy2', 'cache'), join(os.homedir(), '.sbt')],
|
||||
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#scala---sbt
|
||||
pattern: ['**/build.sbt']
|
||||
}
|
||||
];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue