Shard java proto files into groups of 100

Group protoc calls to generate java files into groups of 100
to avoid having a srcjar for every proto file.

Test: m checkbuild
Change-Id: I72a5efaabad24c975282df321d00ec2d7900645e
diff --git a/java/gen.go b/java/gen.go
index b840b60..8a90246 100644
--- a/java/gen.go
+++ b/java/gen.go
@@ -98,6 +98,7 @@
 	flags javaBuilderFlags) android.Paths {
 
 	outSrcFiles := make(android.Paths, 0, len(srcFiles))
+	var protoSrcs android.Paths
 
 	aidlIncludeFlags := genAidlIncludeFlags(srcFiles)
 
@@ -111,13 +112,18 @@
 			javaFile := genLogtags(ctx, srcFile)
 			outSrcFiles = append(outSrcFiles, javaFile)
 		case ".proto":
-			srcJarFile := genProto(ctx, srcFile, flags.proto)
-			outSrcFiles = append(outSrcFiles, srcJarFile)
+			protoSrcs = append(protoSrcs, srcFile)
 		default:
 			outSrcFiles = append(outSrcFiles, srcFile)
 		}
 	}
 
+	// Process all proto files together to support sharding them into one or more rules that produce srcjars.
+	if len(protoSrcs) > 0 {
+		srcJarFiles := genProto(ctx, protoSrcs, flags.proto)
+		outSrcFiles = append(outSrcFiles, srcJarFiles...)
+	}
+
 	return outSrcFiles
 }