java: add one-off build logic for frameworks/base

framework.jar needs to compile against R.java and Manifest.java from
framework-res.apk.  Rather than complicating the Blueprints properties
with values that will only be used once, add one-off logic to
collectDeps to extract the rJarSpec out of the framework-res module.

Change-Id: I1195b1b5e07badc583703479382ceba35300b8fd
diff --git a/java/java.go b/java/java.go
index 215924b..2a04f70 100644
--- a/java/java.go
+++ b/java/java.go
@@ -31,7 +31,6 @@
 
 // TODO:
 // Autogenerated files:
-//  AIDL
 //  Proto
 //  Renderscript
 // Post-jar passes:
@@ -192,7 +191,7 @@
 
 func (j *javaBase) collectDeps(ctx common.AndroidModuleContext) (classpath []string,
 	bootClasspath string, classJarSpecs, resourceJarSpecs []jarSpec, aidlPreprocess string,
-	aidlIncludeDirs []string) {
+	aidlIncludeDirs []string, srcFileLists []string) {
 
 	ctx.VisitDirectDeps(func(module blueprint.Module) {
 		otherName := ctx.OtherModuleName(module)
@@ -205,6 +204,10 @@
 				classpath = append(classpath, javaDep.ClasspathFile())
 				classJarSpecs = append(classJarSpecs, javaDep.ClassJarSpecs()...)
 				resourceJarSpecs = append(resourceJarSpecs, javaDep.ResourceJarSpecs()...)
+			} else if ctx.ModuleName() == "framework" && otherName == "framework-res" {
+				// framework.jar has a one-off dependency on the R.java and Manifest.java files
+				// generated by framework-res.apk
+				srcFileLists = append(srcFileLists, module.(*javaBase).module.(*AndroidApp).rJarSpec.fileList)
 			} else {
 				panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
 			}
@@ -224,7 +227,8 @@
 		}
 	})
 
-	return classpath, bootClasspath, classJarSpecs, resourceJarSpecs, aidlPreprocess, aidlIncludeDirs
+	return classpath, bootClasspath, classJarSpecs, resourceJarSpecs, aidlPreprocess,
+		aidlIncludeDirs, srcFileLists
 }
 
 func (j *javaBase) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) {
@@ -237,7 +241,7 @@
 		common.ModuleSrcDir(ctx))
 
 	classpath, bootClasspath, classJarSpecs, resourceJarSpecs, aidlPreprocess,
-		aidlIncludeDirs := j.collectDeps(ctx)
+		aidlIncludeDirs, srcFileLists := j.collectDeps(ctx)
 
 	var flags javaBuilderFlags
 
@@ -271,7 +275,7 @@
 
 	if len(srcFiles) > 0 {
 		// Compile java sources into .class files
-		classes := TransformJavaToClasses(ctx, srcFiles, flags, javacDeps)
+		classes := TransformJavaToClasses(ctx, srcFiles, srcFileLists, flags, javacDeps)
 		if ctx.Failed() {
 			return
 		}