Bp2build Java libs for java_binary -> java_import edge

Since Bazel's java_import requires a jars attribute to be specified,
the generated neverlink-duplicated module is of type java_library

Change-Id: I14a866dfc583507a9462add50d95060cbfe540c5
Bug: 244210934
Test: m bp2build, go test ./bp2build, manual inspection of generated Build and jar files
diff --git a/bp2build/java_binary_host_conversion_test.go b/bp2build/java_binary_host_conversion_test.go
index 86f3d42..c860844 100644
--- a/bp2build/java_binary_host_conversion_test.go
+++ b/bp2build/java_binary_host_conversion_test.go
@@ -29,6 +29,7 @@
 	RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
 		ctx.RegisterModuleType("cc_library_host_shared", cc.LibraryHostSharedFactory)
 		ctx.RegisterModuleType("java_library", java.LibraryFactory)
+		ctx.RegisterModuleType("java_import_host", java.ImportFactory)
 	}, tc)
 }
 
@@ -102,3 +103,34 @@
 		},
 	})
 }
+
+func TestJavaBinaryHostLibs(t *testing.T) {
+	runJavaBinaryHostTestCase(t, Bp2buildTestCase{
+		Description: "java_binary_host with srcs, libs.",
+		Filesystem:  fs,
+		Blueprint: `java_binary_host {
+    name: "java-binary-host-libs",
+    libs: ["java-lib-dep-1"],
+    manifest: "test.mf",
+    srcs: ["a.java"],
+}
+
+java_import_host{
+    name: "java-lib-dep-1",
+    jars: ["foo.jar"],
+    bazel_module: { bp2build_available: false },
+}
+`,
+		ExpectedBazelTargets: []string{
+			MakeBazelTarget("java_binary", "java-binary-host-libs", AttrNameToString{
+				"main_class": `"com.android.test.MainClass"`,
+				"srcs":       `["a.java"]`,
+				"deps":       `[":java-lib-dep-1-neverlink"]`,
+				"target_compatible_with": `select({
+        "//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
+        "//conditions:default": [],
+    })`,
+			}),
+		},
+	})
+}
diff --git a/bp2build/java_import_conversion_test.go b/bp2build/java_import_conversion_test.go
index 05d7142..ac7dfff 100644
--- a/bp2build/java_import_conversion_test.go
+++ b/bp2build/java_import_conversion_test.go
@@ -48,6 +48,10 @@
 			MakeBazelTarget("java_import", "example_import", AttrNameToString{
 				"jars": `["import.jar"]`,
 			}),
+			MakeBazelTarget("java_library", "example_import-neverlink", AttrNameToString{
+				"exports":   `[":example_import"]`,
+				"neverlink": `True`,
+			}),
 		}})
 }
 
@@ -81,5 +85,35 @@
         "//conditions:default": [],
     })`,
 			}),
+			MakeBazelTarget("java_library", "example_import-neverlink", AttrNameToString{
+				"exports":   `[":example_import"]`,
+				"neverlink": `True`,
+			}),
+		}})
+}
+
+func TestJavaImportHost(t *testing.T) {
+	runJavaImportTestCase(t, Bp2buildTestCase{
+		Description:                "Java import host- simple example",
+		ModuleTypeUnderTest:        "java_import_host",
+		ModuleTypeUnderTestFactory: java.ImportFactory,
+		Filesystem: map[string]string{
+			"import.jar": "",
+		},
+		Blueprint: `
+java_import_host {
+        name: "example_import",
+        jars: ["import.jar"],
+        bazel_module: { bp2build_available: true },
+}
+`,
+		ExpectedBazelTargets: []string{
+			MakeBazelTarget("java_import", "example_import", AttrNameToString{
+				"jars": `["import.jar"]`,
+			}),
+			MakeBazelTarget("java_library", "example_import-neverlink", AttrNameToString{
+				"exports":   `[":example_import"]`,
+				"neverlink": `True`,
+			}),
 		}})
 }