2021-08-20 19:01:43 +00:00
|
|
|
import path from 'path'
|
|
|
|
import fs from 'fs'
|
2021-09-06 17:16:08 +00:00
|
|
|
import {AbstractCache} from './cache-utils'
|
2021-08-20 19:01:43 +00:00
|
|
|
|
2021-09-13 17:47:59 +00:00
|
|
|
// TODO: Maybe allow the user to override / tweak this set
|
2021-08-20 19:01:43 +00:00
|
|
|
const PATHS_TO_CACHE = [
|
|
|
|
'configuration-cache' // Only configuration-cache is stored at present
|
|
|
|
]
|
|
|
|
|
2021-09-06 17:16:08 +00:00
|
|
|
export class ProjectDotGradleCache extends AbstractCache {
|
|
|
|
private rootDir: string
|
|
|
|
constructor(rootDir: string) {
|
|
|
|
super('project', 'Project .gradle directory')
|
|
|
|
this.rootDir = rootDir
|
2021-08-20 19:01:43 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 17:16:08 +00:00
|
|
|
protected cacheOutputExists(): boolean {
|
|
|
|
const dir = this.getProjectDotGradleDir()
|
|
|
|
return fs.existsSync(dir)
|
2021-08-20 19:01:43 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 17:16:08 +00:00
|
|
|
protected getCachePath(): string[] {
|
|
|
|
const dir = this.getProjectDotGradleDir()
|
|
|
|
return PATHS_TO_CACHE.map(x => path.resolve(dir, x))
|
2021-08-20 19:01:43 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 17:16:08 +00:00
|
|
|
private getProjectDotGradleDir(): string {
|
|
|
|
return path.resolve(this.rootDir, '.gradle')
|
2021-08-20 19:01:43 +00:00
|
|
|
}
|
|
|
|
}
|