Bp2Build for libs property in java_library

Bp2build for both *->java_library and java_library->* edges.

Change-Id: I2540c9af2ae2fe7677767d507647b1c6669b9bb7
Bug: 244210934
Test: ./bp2build testcase, manually inspected build files for hamcrest-library, hamcrest targets
diff --git a/java/java.go b/java/java.go
index 25b6349..76b599b 100644
--- a/java/java.go
+++ b/java/java.go
@@ -2606,7 +2606,7 @@
 	if m.properties.Libs != nil {
 
 		// TODO 244210934 ALIX Check if this else statement breaks presubmits get rid of it if it doesn't
-		if strings.HasPrefix(ctx.ModuleType(), "java_binary") {
+		if strings.HasPrefix(ctx.ModuleType(), "java_binary") || strings.HasPrefix(ctx.ModuleType(), "java_library") {
 			for _, d := range m.properties.Libs {
 				neverlinkLabel := android.BazelLabelForModuleDepSingle(ctx, d)
 				neverlinkLabel.Label = neverlinkLabel.Label + "-neverlink"
@@ -2674,12 +2674,21 @@
 		Deps:                 deps,
 		Exports:              depLabels.StaticDeps,
 	}
+	name := m.Name()
 
 	if !bp2BuildInfo.hasKotlinSrcs && len(m.properties.Common_srcs) == 0 {
 		props = bazel.BazelTargetModuleProperties{
 			Rule_class:        "java_library",
 			Bzl_load_location: "//build/bazel/rules/java:library.bzl",
 		}
+
+		ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs)
+		neverlinkProp := true
+		neverLinkAttrs := &javaLibraryAttributes{
+			Exports:   bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}),
+			Neverlink: bazel.BoolAttribute{Value: &neverlinkProp},
+		}
+		ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name + "-neverlink"}, neverLinkAttrs)
 	} else {
 		attrs.Common_srcs = bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, m.properties.Common_srcs))
 
@@ -2687,10 +2696,10 @@
 			Rule_class:        "kt_jvm_library",
 			Bzl_load_location: "@rules_kotlin//kotlin:jvm_library.bzl",
 		}
+		// TODO (b/244210934): create neverlink-duplicate target once kt_jvm_library supports neverlink attribute
+		ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs)
 	}
 
-	name := m.Name()
-	ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs)
 }
 
 type javaBinaryHostAttributes struct {