java: add genrule support to java builds

Add support for source files generated by genrule or gensrcs to
java builds.

Change-Id: I39762b2ab65fa4cf92724300edc4ba995845ce92
diff --git a/java/java.go b/java/java.go
index 292e258..d9aad3c 100644
--- a/java/java.go
+++ b/java/java.go
@@ -27,6 +27,7 @@
 	"github.com/google/blueprint/pathtools"
 
 	"android/soong/common"
+	"android/soong/genrule"
 )
 
 // TODO:
@@ -243,8 +244,6 @@
 					}
 				}
 			}
-		} else {
-			ctx.ModuleErrorf("unknown dependency module type for %q", otherName)
 		}
 	})
 
@@ -294,6 +293,12 @@
 
 	srcFiles = j.genSources(ctx, srcFiles, flags)
 
+	ctx.VisitDirectDeps(func(module blueprint.Module) {
+		if gen, ok := module.(genrule.SourceFileGenerator); ok {
+			srcFiles = append(srcFiles, gen.GeneratedSourceFiles()...)
+		}
+	})
+
 	srcFileLists = append(srcFileLists, j.ExtraSrcLists...)
 
 	if len(srcFiles) > 0 {