diff --git a/java/core/BUILD.bazel b/java/core/BUILD.bazel index b896c426b9..57f9d61512 100644 --- a/java/core/BUILD.bazel +++ b/java/core/BUILD.bazel @@ -540,3 +540,72 @@ pkg_files( strip_prefix = strip_prefix.from_root(""), visibility = ["//java:__pkg__"], ) + +# Genrules to expose test gencode srcjars / jars for testing compatibility of old gencode against newer runtimes. +genrule( + name = "generic_test_protos_java_proto_srcjar", + srcs = [ + "//java/core:java_test_protos_java_proto", + "//java/core:generic_test_protos_java_proto", + "//java/core:lite_test_protos_java_proto", + ], + outs = [ + "java_test_protos-speed.srcjar", + "generic_test_protos-speed.srcjar", + "lite_test_protos-speed.srcjar", + ], + visibility = [ + "//visibility:public", + ], + cmd = """ + for location in $(locations //java/core:java_test_protos_java_proto); do + if [[ $$(basename $$location) == 'java_test_protos-speed-src.jar' ]]; then + cp $$location $(location java_test_protos-speed.srcjar); + fi + done; + for location in $(locations //java/core:generic_test_protos_java_proto); do + if [[ $$(basename $$location) == 'generic_test_protos-speed-src.jar' ]]; then + cp $$location $(location generic_test_protos-speed.srcjar); + fi + done; + for location in $(locations //java/core:lite_test_protos_java_proto); do + if [[ $$(basename $$location) == 'lite_test_protos-speed-src.jar' ]]; then + cp $$location $(location lite_test_protos-speed.srcjar); + fi + done; + """, +) + +genrule( + name = "generic_test_protos_java_proto_jar", + srcs = [ + "//java/core:java_test_protos_java_proto", + "//java/core:generic_test_protos_java_proto", + "//java/core:lite_test_protos_java_proto", + ], + outs = [ + "libjava_test_protos-speed.jar", + "libgeneric_test_protos-speed.jar", + "liblite_test_protos-speed.jar", + ], + visibility = [ + "//visibility:public", + ], + cmd = """ + for location in $(locations //java/core:java_test_protos_java_proto); do + if [[ $$(basename $$location) == 'libjava_test_protos-speed.jar' ]]; then + cp $$location $(location libjava_test_protos-speed.jar); + fi + done; + for location in $(locations //java/core:generic_test_protos_java_proto); do + if [[ $$(basename $$location) == 'libgeneric_test_protos-speed.jar' ]]; then + cp $$location $(location libgeneric_test_protos-speed.jar); + fi + done; + for location in $(locations //java/core:lite_test_protos_java_proto); do + if [[ $$(basename $$location) == 'liblite_test_protos-speed.jar' ]]; then + cp $$location $(location liblite_test_protos-speed.jar); + fi + done; + """, +) \ No newline at end of file