From 49889c088b22278436d754ee6d2fbc666df59477 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 26 Jul 2023 16:16:47 -0700 Subject: [PATCH] Delete the javac/classes directory after zipping it javac produces a directory containing class files, which is then zipped with soong_zip into a jar file. The class files are never used outside of the rule, so delete them after zipping them. This should save 19 GB of disk space in checkbuilds. Do the same for kotlinc/classes directories for consistency. Bug: 293352015 Test: treehugger Change-Id: Id1e889cfbee47eab552a5bb27134fa4b3b4c4d14 --- java/builder.go | 2 +- java/kotlin.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/java/builder.go b/java/builder.go index afbd69ee4..debf49a00 100644 --- a/java/builder.go +++ b/java/builder.go @@ -55,7 +55,7 @@ var ( `$zipTemplate${config.SoongZipCmd} -jar -o $out.tmp -C $outDir -D $outDir && ` + `if ! cmp -s "$out.tmp" "$out"; then mv "$out.tmp" "$out"; fi && ` + `if ! cmp -s "$annoSrcJar.tmp" "$annoSrcJar"; then mv "$annoSrcJar.tmp" "$annoSrcJar"; fi && ` + - `rm -rf "$srcJarDir"`, + `rm -rf "$srcJarDir" "$outDir"`, CommandDeps: []string{ "${config.JavacCmd}", "${config.SoongZipCmd}", diff --git a/java/kotlin.go b/java/kotlin.go index f28d6c737..3637e2e71 100644 --- a/java/kotlin.go +++ b/java/kotlin.go @@ -42,7 +42,7 @@ var kotlinc = pctx.AndroidRemoteStaticRule("kotlinc", android.RemoteRuleSupports ` -P plugin:org.jetbrains.kotlin.jvm.abi:outputDir=$headerClassesDir && ` + `${config.SoongZipCmd} -jar -o $out -C $classesDir -D $classesDir -write_if_changed && ` + `${config.SoongZipCmd} -jar -o $headerJar -C $headerClassesDir -D $headerClassesDir -write_if_changed && ` + - `rm -rf "$srcJarDir"`, + `rm -rf "$srcJarDir" "$classesDir" "$headerClassesDir"`, CommandDeps: []string{ "${config.KotlincCmd}", "${config.KotlinCompilerJar}",