2021-08-20 13:01:43 -06:00
|
|
|
import path from 'path'
|
2021-10-30 07:15:20 -06:00
|
|
|
import {AbstractCache} from './cache-base'
|
2021-08-20 13:01:43 -06:00
|
|
|
|
2021-09-13 11:47:59 -06:00
|
|
|
// TODO: Maybe allow the user to override / tweak this set
|
2021-08-20 13:01:43 -06:00
|
|
|
const PATHS_TO_CACHE = [
|
|
|
|
'configuration-cache' // Only configuration-cache is stored at present
|
|
|
|
]
|
|
|
|
|
2021-11-28 10:19:56 -07:00
|
|
|
/**
|
|
|
|
* A simple cache that saves and restores the '.gradle/configuration-cache' directory in the project root.
|
|
|
|
*/
|
2021-09-06 11:16:08 -06:00
|
|
|
export class ProjectDotGradleCache extends AbstractCache {
|
|
|
|
private rootDir: string
|
|
|
|
constructor(rootDir: string) {
|
2021-10-30 07:39:21 -06:00
|
|
|
super('project', 'Project configuration cache')
|
2021-09-06 11:16:08 -06:00
|
|
|
this.rootDir = rootDir
|
2021-08-20 13:01:43 -06:00
|
|
|
}
|
|
|
|
|
2021-09-06 11:16:08 -06:00
|
|
|
protected getCachePath(): string[] {
|
|
|
|
const dir = this.getProjectDotGradleDir()
|
|
|
|
return PATHS_TO_CACHE.map(x => path.resolve(dir, x))
|
2021-08-20 13:01:43 -06:00
|
|
|
}
|
|
|
|
|
2021-09-06 11:16:08 -06:00
|
|
|
private getProjectDotGradleDir(): string {
|
|
|
|
return path.resolve(this.rootDir, '.gradle')
|
2021-08-20 13:01:43 -06:00
|
|
|
}
|
|
|
|
}
|