gn2bp: Create `java_genrule` from java actions

* Actions whose outputs are "srcjar" and ".java" files only are converted into a `java_genrule` instead of `cc_genrule`. The only exception to this is the jni_registration_module which produces a header file and a srcjar, it's kept a cc_genrule but deep-copied by create_java_module to have a java_genrule copy.

Test: None
Change-Id: I07270c9a7984a8fd26a53ca614287a3a646d65d6
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index d120199..e54cb31 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -397,7 +397,7 @@
     return write_blueprint_key_value(output, name, value, sort)
 
   def is_compiled(self):
-    return self.type not in ('cc_genrule', 'filegroup', 'cc_defaults')
+    return self.type not in ('cc_genrule', 'filegroup', 'java_genrule')
 
   def is_genrule(self):
     return self.type == "cc_genrule"
@@ -830,11 +830,11 @@
         new_args.append(arg)
 
   target.args = new_args
-  return create_action_module(blueprint, target)
+  return create_action_module(blueprint, target, 'cc_genrule')
 
-def create_action_module(blueprint, target):
+def create_action_module(blueprint, target, type):
   bp_module_name = label_to_module_name(target.name)
-  module = Module('cc_genrule', bp_module_name, target.name)
+  module = Module(type, bp_module_name, target.name)
 
   sanitizer = get_action_sanitizer(target)
   target.args = sanitizer.get_args()
@@ -964,7 +964,6 @@
                                  for d in include_dirs
                                  if not re.match('^//out/.*', d)])
 
-
 def create_modules_from_target(blueprint, gn, gn_target_name):
   """Generate module(s) for a given GN target.
 
@@ -1004,7 +1003,15 @@
     if module is None:
       return None
   elif target.type == 'action':
-    module = create_action_module(blueprint, target)
+    if gn_utils.is_java_action(target.script, target.outputs) and \
+        target.name != "//components/cronet/android:cronet_jni_registration":
+      # This is a cc_genrule that generates both a c++ header file and
+      # srcjar for java. Treat it as a cc_genrule for the time being while
+      # making anothe deep copy of the module and append _java to it for
+      # the java_library.
+      module = create_action_module(blueprint, target, 'java_genrule')
+    else:
+      module = create_action_module(blueprint, target, 'cc_genrule')
   elif target.type == 'action_foreach':
     module = create_action_foreach_modules(blueprint, target)
   elif target.type == 'copy':