Add source distribution packaging rules (#9835)

This change adds `rules_pkg`-based targets that will produce source distribution archives, similar to `make dist`.

These rules produce nearly the same outputs as `make dist`. However, there are some differences and caveats:

1. The outputs do not contain vendored googletest sources.
2. You have to run `autogen.sh` before `blaze build pkg:all`. This produces several autotools-related files directly into the source tree.
3. The output .zip files do not have a directory prefix like `protobuf-3.20.1-rc-1` (this will be addressed after [Substitute package variables in `pkg_zip#package_dir`. bazelbuild/rules_pkg#577](https://github.com/bazelbuild/rules_pkg/pull/577); the tar files do have this prefix, though.)
4. One file is missing from the archives, which is produced during the `make` build: benchmarks/gogo/cpp_no_group/cpp_benchmark.cc
5. In several places, I have explicitly excluded some files that are not in the autotools distribution outputs. I think most of those files should probably be included, but for now, I'm aiming for parity with `make dist`. These are marked with comments, so it should be easy to clean them up later.
diff --git a/java/core/BUILD b/java/core/BUILD
index 011fb1c..685ebd0 100644
--- a/java/core/BUILD
+++ b/java/core/BUILD
@@ -1,6 +1,7 @@
 load("@bazel_skylib//rules:build_test.bzl", "build_test")
 load("@rules_java//java:defs.bzl", "java_library", "java_lite_proto_library", "java_proto_library")
 load("@rules_jvm_external//:defs.bzl", "java_export")
+load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
 load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain", "proto_library")
 load("//:internal.bzl", "conformance_test")
 load("//:protobuf_version.bzl", "PROTOBUF_VERSION")
@@ -175,9 +176,6 @@
 
 proto_lang_toolchain(
     name = "toolchain",
-    command_line = "--java_out=$(OUT)",
-    runtime = ":core",
-    visibility = ["//visibility:public"],
     # keep this in sync w/ WELL_KNOWN_PROTO_MAP in //:BUILD
     blacklisted_protos = [
         "//:any_proto",
@@ -193,6 +191,9 @@
         "//:type_proto",
         "//:wrappers_proto",
     ],
+    command_line = "--java_out=$(OUT)",
+    runtime = ":core",
+    visibility = ["//visibility:public"],
 )
 
 proto_library(
@@ -226,6 +227,7 @@
         "src/test/java/com/google/protobuf/TestUtil.java",
         "src/test/java/com/google/protobuf/TestUtilLite.java",
     ],
+    visibility = ["//java:__subpackages__"],
     deps = [
         ":core",
         ":generic_test_protos_java_proto",
@@ -233,7 +235,6 @@
         "@maven//:com_google_guava_guava",
         "@maven//:junit_junit",
     ],
-    visibility = ["//java:__subpackages__"],
 )
 
 test_suite(
@@ -336,8 +337,8 @@
         ":rewrite_javalite_test_util",
     ],
     visibility = [
-        "//java/lite:__pkg__",
         "//java/kotlin-lite:__pkg__",
+        "//java/lite:__pkg__",
     ],
     deps = [
         ":generic_test_protos_java_proto_lite",
@@ -411,3 +412,20 @@
         "@maven//:org_mockito_mockito_core",
     ],
 )
+
+pkg_files(
+    name = "dist_files",
+    srcs = glob([
+        "src/main/java/com/google/protobuf/*.java",
+        "src/test/java/**/*.java",
+        "src/test/proto/**/*.proto",
+    ]) + [
+        "BUILD",
+        "generate-sources-build.xml",
+        "generate-test-sources-build.xml",
+        "pom.xml",
+        "pom_template.xml",
+    ],
+    strip_prefix = strip_prefix.from_root(""),
+    visibility = ["//java:__pkg__"],
+)