Remove osgi dependency from main java libraries.

//java:core, //java:lite, and //java:util shouldn't have this extra dependency. For now, we just add a separate version but we will look into using the java_library in protobuf_versioned_java_library in the future.

PiperOrigin-RevId: 527643325
diff --git a/java/core/BUILD.bazel b/java/core/BUILD.bazel
index 49bf0e0..8f2bfe3 100644
--- a/java/core/BUILD.bazel
+++ b/java/core/BUILD.bazel
@@ -121,11 +121,21 @@
 )
 
 # Should be used as `//java/lite`.
-protobuf_versioned_java_library(
+java_library(
     name = "lite",
     srcs = LITE_SRCS + [
         ":gen_well_known_protos_javalite",
     ],
+    visibility = [
+        "//java/lite:__pkg__",
+    ],
+)
+
+protobuf_versioned_java_library(
+    name = "lite_bundle",
+    srcs = LITE_SRCS + [
+        ":gen_well_known_protos_javalite",
+    ],
     bundle_description = "Lite version of Protocol Buffers library. This " +
                          "version is optimized for code size, but does not " +
                          "guarantee API/ABI stability.",
@@ -145,7 +155,7 @@
         "//:lite_well_known_protos",
     ],
     tags = ["manual"],
-    runtime_deps = [":lite"],
+    runtime_deps = [":lite_bundle"],
 )
 
 protobuf_java_library(
@@ -171,7 +181,7 @@
     ],
 )
 
-protobuf_versioned_java_library(
+java_library(
     name = "core",
     srcs = glob(
         [
@@ -181,6 +191,25 @@
     ) + [
         ":gen_well_known_protos_java",
     ],
+    visibility = ["//visibility:public"],
+    exports = [
+        ":lite_runtime_only",
+    ],
+    deps = [
+        ":lite_runtime_only",
+    ],
+)
+
+protobuf_versioned_java_library(
+    name = "core_bundle",
+    srcs = glob(
+        [
+            "src/main/java/com/google/protobuf/*.java",
+        ],
+        exclude = LITE_SRCS,
+    ) + [
+        ":gen_well_known_protos_java",
+    ],
     bundle_description = "Core Protocol Buffers library. Protocol Buffers " +
                          "are a way of encoding structured data in an " +
                          "efficient yet extensible format.",
@@ -205,7 +234,7 @@
         "//src/google/protobuf:descriptor_proto_srcs",
     ],
     tags = ["manual"],
-    runtime_deps = [":core"],
+    runtime_deps = [":core_bundle"],
 )
 
 filegroup(
diff --git a/java/util/BUILD.bazel b/java/util/BUILD.bazel
index 1bb2358..c6ab799 100644
--- a/java/util/BUILD.bazel
+++ b/java/util/BUILD.bazel
@@ -5,11 +5,27 @@
 load("//:protobuf_version.bzl", "PROTOBUF_JAVA_VERSION")
 load("//java/internal:testing.bzl", "junit_tests")
 
-protobuf_versioned_java_library(
+java_library(
     name = "util",
     srcs = glob([
         "src/main/java/com/google/protobuf/util/*.java",
     ]),
+    visibility = ["//visibility:public"],
+    deps = [
+        "//java/core",
+        "@maven//:com_google_code_findbugs_jsr305",
+        "@maven//:com_google_code_gson_gson",
+        "@maven//:com_google_errorprone_error_prone_annotations",
+        "@maven//:com_google_guava_guava",
+        "@maven//:com_google_j2objc_j2objc_annotations",
+    ],
+)
+
+protobuf_versioned_java_library(
+    name = "util_bundle",
+    srcs = glob([
+        "src/main/java/com/google/protobuf/util/*.java",
+    ]),
     bundle_description = "Utilities for Protocol Buffers",
     bundle_name = "Protocol Buffers [Util]",
     bundle_symbolic_name = "com.google.protobuf.util",
@@ -32,7 +48,7 @@
     pom_template = "pom_template.xml",
     tags = ["manual"],
     visibility = ["//java:__pkg__"],
-    runtime_deps = [":util"],
+    runtime_deps = [":util_bundle"],
 )
 
 filegroup(