mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-12-25 15:06:19 +08:00
Remove downloaded wrapper zips before caching
The wrapper zip files are redundant, and not required after extraction. Gradle 7.5+ will delete these automatically, but we delete them for older versions to avoid caching the wrapper distributions twice. Sinc the `gradle-home-cache-excludes` parameter does not support wildcards, we remove them explicitly.
This commit is contained in:
parent
e3ceb00204
commit
f2bb19b43a
@ -294,6 +294,28 @@ export class GradleHomeEntryExtractor extends AbstractEntryExtractor {
|
|||||||
super(gradleUserHome, 'gradle-home')
|
super(gradleUserHome, 'gradle-home')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async extract(listener: CacheListener): Promise<void> {
|
||||||
|
await this.deleteWrapperZips()
|
||||||
|
return super.extract(listener)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete any downloaded wrapper zip files that are not needed after extraction.
|
||||||
|
* These files are cleaned up by Gradle >= 7.5, but for older versions we remove them manually.
|
||||||
|
*/
|
||||||
|
private async deleteWrapperZips(): Promise<void> {
|
||||||
|
const wrapperZips = path.resolve(this.gradleUserHome, 'wrapper/dists/*/*/*.zip')
|
||||||
|
const globber = await glob.create(wrapperZips, {
|
||||||
|
implicitDescendants: false,
|
||||||
|
followSymbolicLinks: false
|
||||||
|
})
|
||||||
|
|
||||||
|
for (const p of await globber.glob()) {
|
||||||
|
cacheDebug(`Deleting wrapper zip: ${p}`)
|
||||||
|
tryDelete(p)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the extracted cache entry definitions, which determine which artifacts will be cached
|
* Return the extracted cache entry definitions, which determine which artifacts will be cached
|
||||||
* separately from the rest of the Gradle User Home cache entry.
|
* separately from the rest of the Gradle User Home cache entry.
|
||||||
@ -316,7 +338,7 @@ export class GradleHomeEntryExtractor extends AbstractEntryExtractor {
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
entryDefinition('generated-gradle-jars', ['caches/*/generated-gradle-jars/*.jar'], false),
|
entryDefinition('generated-gradle-jars', ['caches/*/generated-gradle-jars/*.jar'], false),
|
||||||
entryDefinition('wrapper-zips', ['wrapper/dists/*/*/*/'], false), // Directories only
|
entryDefinition('wrapper-zips', ['wrapper/dists/*/*/'], false), // Entire wrapper directory cached together
|
||||||
entryDefinition('java-toolchains', ['jdks/*.zip', 'jdks/*.tar.gz'], false),
|
entryDefinition('java-toolchains', ['jdks/*.zip', 'jdks/*.tar.gz'], false),
|
||||||
entryDefinition('dependencies', ['caches/modules-*/files-*/*/*/*/*'], true),
|
entryDefinition('dependencies', ['caches/modules-*/files-*/*/*/*/*'], true),
|
||||||
entryDefinition('instrumented-jars', ['caches/jars-*/*'], true),
|
entryDefinition('instrumented-jars', ['caches/jars-*/*'], true),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user