Miscellaneous fixes for java compiling
Remove java out directory before compiling to avoid incremental compile
issues. Move the rspfile out of the out directory so it doesn't get
deleted. cc->javac in the javac rule. Don't call javac if there
are no source files.
Change-Id: I0bb06c214da54a587bd9e7c9d17caaf0ed1e595e
diff --git a/java/builder.go b/java/builder.go
index 02d65aa..d939e6a 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -37,10 +37,11 @@
// this, all java rules write into separate directories and then a post-processing step lists
// the files in the the directory into a list file that later rules depend on (and sometimes
// read from directly using @<listfile>)
- cc = pctx.StaticRule("javac",
+ javac = pctx.StaticRule("javac",
blueprint.RuleParams{
- Command: `$javacCmd -encoding UTF-8 $javacFlags $bootClasspath $classpath ` +
- `-extdirs "" -d $outDir @$out.rsp || ( rm -rf $outDir; exit 41 ) && ` +
+ Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` +
+ `$javacCmd -encoding UTF-8 $javacFlags $bootClasspath $classpath ` +
+ `-extdirs "" -d $outDir @$out.rsp || ( rm -rf "$outDir"; exit 41 ) && ` +
`find $outDir -name "*.class" > $out`,
Rspfile: "$out.rsp",
RspfileContent: "$in",
@@ -112,10 +113,10 @@
flags javaBuilderFlags, deps []string) jarSpec {
classDir := filepath.Join(common.ModuleOutDir(ctx), "classes")
- classFileList := filepath.Join(classDir, "classes.list")
+ classFileList := filepath.Join(common.ModuleOutDir(ctx), "classes.list")
ctx.Build(pctx, blueprint.BuildParams{
- Rule: cc,
+ Rule: javac,
Outputs: []string{classFileList},
Inputs: srcFiles,
Implicits: deps,