Add support for .srcjar files from genrules and srcs

Allow srcs to contain .srcjar files, which will be extracted just
before javac.  Also allow genrules and generated sources to directly
return .srcjar files.

Test: m checkbuild
Change-Id: Ie4cf60ecb9d2ec63a4c2275221544203b1383597
diff --git a/java/config/config.go b/java/config/config.go
index d4994a1..3cd2841 100644
--- a/java/config/config.go
+++ b/java/config/config.go
@@ -70,7 +70,7 @@
 	pctx.SourcePathVariable("JrtFsJar", "${JavaHome}/lib/jrt-fs.jar")
 	pctx.SourcePathVariable("Ziptime", "prebuilts/build-tools/${hostPrebuiltTag}/bin/ziptime")
 
-	pctx.SourcePathVariable("ExtractSrcJarsCmd", "build/soong/scripts/extract-src-jars.sh")
+	pctx.SourcePathVariable("ExtractSrcJarsCmd", "build/soong/scripts/extract-srcjars.sh")
 	pctx.SourcePathVariable("JarArgsCmd", "build/soong/scripts/jar-args.sh")
 	pctx.HostBinToolVariable("SoongZipCmd", "soong_zip")
 	pctx.HostBinToolVariable("MergeZipsCmd", "merge_zips")
diff --git a/java/gen.go b/java/gen.go
index 8fa199e..c73a446 100644
--- a/java/gen.go
+++ b/java/gen.go
@@ -85,7 +85,7 @@
 }
 
 func (j *Module) genSources(ctx android.ModuleContext, srcFiles android.Paths,
-	flags javaBuilderFlags) (android.Paths, android.Paths) {
+	flags javaBuilderFlags) android.Paths {
 
 	var protoFiles android.Paths
 	outSrcFiles := make(android.Paths, 0, len(srcFiles))
@@ -106,17 +106,15 @@
 		}
 	}
 
-	var outSrcJars android.Paths
-
 	if len(protoFiles) > 0 {
-		protoSrcJar := android.PathForModuleGen(ctx, "proto.src.jar")
+		protoSrcJar := android.PathForModuleGen(ctx, "proto.srcjar")
 		genProto(ctx, protoSrcJar, protoFiles,
 			flags.protoFlags, flags.protoOutFlag, "")
 
-		outSrcJars = append(outSrcJars, protoSrcJar)
+		outSrcFiles = append(outSrcFiles, protoSrcJar)
 	}
 
-	return outSrcFiles, outSrcJars
+	return outSrcFiles
 }
 
 func LogtagsSingleton() blueprint.Singleton {
diff --git a/java/java.go b/java/java.go
index 8a9b31f..b2bd2b0 100644
--- a/java/java.go
+++ b/java/java.go
@@ -550,8 +550,9 @@
 		flags = protoFlags(ctx, &j.protoProperties, flags)
 	}
 
-	var srcJars android.Paths
-	srcFiles, srcJars = j.genSources(ctx, srcFiles, flags)
+	srcFiles = j.genSources(ctx, srcFiles, flags)
+
+	srcJars := srcFiles.FilterByExt(".srcjar")
 	srcJars = append(srcJars, deps.srcJars...)
 	srcJars = append(srcJars, j.ExtraSrcJars...)