mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-12-26 03:16:19 +08:00
31 lines
868 B
TypeScript
31 lines
868 B
TypeScript
import path from 'path'
|
|
import fs from 'fs'
|
|
import {AbstractCache} from './cache-utils'
|
|
|
|
// TODO: Maybe allow the user to override / tweak this set
|
|
const PATHS_TO_CACHE = [
|
|
'configuration-cache' // Only configuration-cache is stored at present
|
|
]
|
|
|
|
export class ProjectDotGradleCache extends AbstractCache {
|
|
private rootDir: string
|
|
constructor(rootDir: string) {
|
|
super('project', 'Project .gradle directory')
|
|
this.rootDir = rootDir
|
|
}
|
|
|
|
protected cacheOutputExists(): boolean {
|
|
const dir = this.getProjectDotGradleDir()
|
|
return fs.existsSync(dir)
|
|
}
|
|
|
|
protected getCachePath(): string[] {
|
|
const dir = this.getProjectDotGradleDir()
|
|
return PATHS_TO_CACHE.map(x => path.resolve(dir, x))
|
|
}
|
|
|
|
private getProjectDotGradleDir(): string {
|
|
return path.resolve(this.rootDir, '.gradle')
|
|
}
|
|
}
|