mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-12-27 17:14:51 -05:00
6d1455a33e
- Extracted common code for Gradle User Home and Project .gradle caches into abstract supertype. - Improve error handling by checking error types
27 lines
843 B
TypeScript
27 lines
843 B
TypeScript
import path from 'path'
|
|
import fs from 'fs'
|
|
import os from 'os'
|
|
|
|
import {AbstractCache} from './cache-utils'
|
|
|
|
const CACHE_PATH = [
|
|
'~/.gradle/caches/*', // All directories in 'caches'
|
|
'~/.gradle/notifications/*', // Prevent the re-rendering of first-use message for version
|
|
'~/.gradle/wrapper/dists/*/*/*.zip' // Only wrapper zips are required : Gradle will expand these on demand
|
|
]
|
|
|
|
export class GradleUserHomeCache extends AbstractCache {
|
|
constructor() {
|
|
super('gradle', 'Gradle User Home')
|
|
}
|
|
|
|
protected cacheOutputExists(): boolean {
|
|
// Need to check for 'caches' directory to avoid incorrect detection on MacOS agents
|
|
const dir = path.resolve(os.homedir(), '.gradle/caches')
|
|
return fs.existsSync(dir)
|
|
}
|
|
|
|
protected getCachePath(): string[] {
|
|
return CACHE_PATH
|
|
}
|
|
}
|