Skip to content

Commit d10013d

Browse files
comiuscopybara-github
authored andcommitted
Separate java_tools into platform independent and prebuilt part.
java_tools is repository package containing tools needed during Java compilation: JavaBuilder, patches for Java compiler, ijar, singlejar, ... Most of the files are jars with Java classes. java_tools are released for three platforms: linux, windows and darwin, however the only difference is in two binaries: ijar and singlejar. This is part one of splitting java_tools and releasing split version (following PR makes use of released split version in Bazel) Java_tools used to be released for multiple Java versions, but all the releases were the same except a some string substitutions in BUILD file. I changed to build only a single version, since it already supports Java from 8 to 14. Changes: - BUILD.java_tools is split into BUILD.java_tools_prebuilt (where the second contains prebuilt binaries) - toolchain definitions are removed from BUILD.java_tools and will be added to tools/jdk/BUILD in the second part - java_toolchain_default.bzl.java_tools is removed (default_java_toolchain.bzl will be updated with its features in the second part). - src/BUILD: JAVA_VERSION is removed, targets used to build java_tools.zip are duplicated to build java_tools_prebuilt.zip (done some cleanup as well) - upload_all_java_tools.sh and upload_java_tools.sh: used by Build kite, I removed java_version over the release, but kept it over tests (for different JDKs) - create_java_tools_release.sh: used by the user in the release process - added platform independent part - tests are updated to use platform independent and platform files, some tests had to be disabled and will be reenabled after the release Closes #12546. PiperOrigin-RevId: 344319092
1 parent 079bb7d commit d10013d

16 files changed

+445
-706
lines changed

src/BUILD

Lines changed: 157 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -552,181 +552,179 @@ sh_binary(
552552
visibility = ["//visibility:public"],
553553
)
554554

555+
# The java_tools release process produces following zip files:
556+
# - java_tools_dist.zip: all sources (Java and C++)
557+
# - java_tools.zip: platform independent part - Java classes (deploy jars) and C++ sources
558+
# - java_tools_prebuilt.zip: C++ binaries (for platforms: Linux, Darwin and Windows)
559+
#
560+
# The files are then used in Bazel as @remote_java_tools and @remote_java_tools_{platform}
561+
# repositories.
562+
# The zip files are not embedded or used in Bazel.
563+
564+
# Following target build java_tools_dist.zip - the sources
565+
genrule(
566+
name = "java_tools_dist",
567+
srcs = [
568+
"//src/java_tools/buildjar:srcs",
569+
"//src/java_tools/junitrunner:srcs",
570+
"//src/java_tools/singlejar:srcs",
571+
"//src/tools/singlejar:embedded_java_tools",
572+
"//third_party/checker_framework_dataflow:srcs",
573+
"//third_party/checker_framework_javacutil:srcs",
574+
"//third_party/ijar:transitive_sources",
575+
"//third_party/java/jacoco:transitive_sources",
576+
"//third_party/java/proguard:srcs",
577+
"@java_tools_langtools_javac11//:srcs",
578+
],
579+
outs = ["java_tools_dist.zip"],
580+
cmd = "zip -qXr $@ $$(echo $(SRCS) | sort)",
581+
output_to_bindir = 1,
582+
visibility = ["//src/test/shell/bazel:__pkg__"],
583+
)
584+
585+
# Following targets build java_tools.zip - platform independent part of java_tools
586+
# It is painstainkingly built by renaming single files, zipping them and merging zips together
587+
# TODO(bazel-team): Replace this with a single target, for example "release_archive" in rules_kotlin
555588
JAVA_TOOLS_DEPLOY_JARS = [
556589
"//src/java_tools/buildjar:JavaBuilder_deploy.jar",
557590
"//src/java_tools/buildjar:VanillaJavaBuilder_deploy.jar",
558591
"//src/java_tools/buildjar/java/com/google/devtools/build/buildjar/genclass:GenClass_deploy.jar",
559592
"//src/java_tools/buildjar/java/com/google/devtools/build/java/turbine:turbine_direct_binary_deploy.jar",
560593
"//src/java_tools/junitrunner/java/com/google/testing/coverage:JacocoCoverage_jarjar_deploy.jar",
561594
"//src/java_tools/junitrunner/java/com/google/testing/junit/runner:Runner_deploy.jar",
562-
] + select({
563-
"//src/conditions:arm": ["//src/java_tools/singlejar/java/com/google/devtools/build/singlejar:bazel-singlejar_deploy.jar"],
564-
"//conditions:default": [],
565-
})
595+
"//src/java_tools/singlejar/java/com/google/devtools/build/singlejar:bazel-singlejar_deploy.jar",
596+
]
566597

567-
JAVA_VERSIONS = ("11",)
598+
genrule(
599+
name = "jars_java_tools_zip",
600+
srcs = JAVA_TOOLS_DEPLOY_JARS + [
601+
"@java_tools_langtools_javac11//:jdk_compiler_jar",
602+
"@java_tools_langtools_javac11//:java_compiler_jar",
603+
"@java_tools_langtools_javac11//:javac_jar",
604+
],
605+
outs = ["jars_java_tools.zip"],
606+
cmd = "zip -qjX $@ $$(echo $(SRCS) | sort)",
607+
visibility = ["//visibility:private"],
608+
)
568609

569-
[
570-
genrule(
571-
name = "jars_java_tools_java" + java_version + "_zip",
572-
srcs = JAVA_TOOLS_DEPLOY_JARS + [
573-
"@java_tools_langtools_javac11//:jdk_compiler_jar",
574-
"@java_tools_langtools_javac11//:java_compiler_jar",
575-
"@java_tools_langtools_javac11//:javac_jar",
576-
],
577-
outs = ["jars_java_tools_java" + java_version + ".zip"],
578-
cmd = "zip -qjX $@ $$(echo $(SRCS) | sort)",
579-
visibility = ["//visibility:private"],
580-
)
581-
for java_version in JAVA_VERSIONS
582-
]
610+
genrule(
611+
name = "java_tools_build_zip",
612+
srcs = ["//tools/jdk:BUILD.java_tools"],
613+
outs = ["java_tools_build.zip"],
614+
cmd = "cat $(SRCS) > BUILD; zip -qjX $@ BUILD",
615+
)
583616

584-
[
585-
genrule(
586-
name = "java_tools_dist_java" + java_version,
587-
srcs = [
588-
"//src/java_tools/buildjar:srcs",
589-
"//src/java_tools/junitrunner:srcs",
590-
"//src/java_tools/singlejar:srcs",
591-
"//src/tools/singlejar:embedded_java_tools",
592-
"//third_party/checker_framework_dataflow:srcs",
593-
"//third_party/checker_framework_javacutil:srcs",
594-
"//third_party/ijar:transitive_sources",
595-
"//third_party/java/jacoco:transitive_sources",
596-
"//third_party/java/proguard:srcs",
597-
"@java_tools_langtools_javac11//:srcs",
598-
],
599-
outs = ["java_tools_dist_javac" + java_version + ".zip"],
600-
cmd = "zip -qXr $@ $$(echo $(SRCS) | sort)",
601-
output_to_bindir = 1,
602-
visibility = ["//src/test/shell/bazel:__pkg__"],
603-
)
604-
for java_version in JAVA_VERSIONS
605-
]
617+
genrule(
618+
name = "java_tools_no_build_zip",
619+
srcs = [
620+
":jars_java_tools.zip",
621+
"//src/tools/singlejar:singlejar_transitive_zip",
622+
"//third_party/ijar:ijar_transitive_srcs_zip",
623+
"//third_party/java/jacoco:jacoco_jars_zip",
624+
"//third_party/java/proguard:proguard_zip",
625+
],
626+
outs = ["java_tools_no_build.zip"],
627+
cmd = "$(location //src:merge_zip_files) java_tools $@ $(SRCS)",
628+
output_to_bindir = 1,
629+
tools = ["//src:merge_zip_files"],
630+
visibility = ["//src/test/shell/bazel:__pkg__"],
631+
)
606632

607-
[
608-
# Targets used by the java_tools_binaries Buildkite pipeline to build the
609-
# java_tools_dist_java* zips and upload them to a tmp directory in GCS.
610-
sh_binary(
611-
name = "upload_java_tools_dist_java" + java_version,
612-
srcs = ["upload_java_tools.sh"],
613-
args = [
614-
"--java_tools_zip",
615-
"src/java_tools_dist_javac" + java_version + ".zip",
616-
"--gcs_java_tools_dir",
617-
"tmp/sources",
618-
"--java_version",
619-
java_version,
620-
"--platform",
621-
] + select({
622-
"//src/conditions:darwin": ["darwin"],
623-
"//src/conditions:windows": ["windows"],
624-
"//src/conditions:linux": ["linux"],
625-
"//conditions:default": ["unknown"],
626-
}),
627-
data = [":java_tools_dist_java" + java_version],
628-
deps = ["@bazel_tools//tools/bash/runfiles"],
629-
)
630-
for java_version in JAVA_VERSIONS
631-
]
633+
genrule(
634+
name = "java_tools_zip",
635+
srcs = [
636+
"java_tools_no_build.zip",
637+
"java_tools_build.zip",
638+
],
639+
outs = ["java_tools.zip"],
640+
cmd = "$(location //src:merge_zip_files) - $@ $(SRCS)",
641+
output_to_bindir = 1,
642+
tools = ["//src:merge_zip_files"],
643+
visibility = ["//src/test/shell/bazel:__pkg__"],
644+
)
632645

633-
[
634-
# The java_tools releases can have BUILD files that vary depending on the
635-
# javac version they embed. Currently the only difference is in the
636-
# java_toolchain source version which has to be 14 for javac 14 to be able
637-
# to build new Java 14 features. This is not used atm, as the toolchain for
638-
# javac 14 was duplicated, but it might be used in future Bazel releases to
639-
# support new javac release, so that we preserve this step for now.
640-
[
641-
genrule(
642-
name = "create_java_tools_build_java" + java_version,
643-
srcs = ["//tools/jdk:BUILD.java_tools"],
644-
outs = ["remote_java_tools_java" + java_version + "/BUILD"],
645-
cmd = "sed 's/JAVA_LANGUAGE_LEVEL/" + java_version + "/g' $< > $@",
646-
),
647-
genrule(
648-
name = "create_java_tools_default_java" + java_version,
649-
srcs = ["//tools/jdk:java_toolchain_default.bzl.java_tools"],
650-
outs = ["remote_java_tools_java" + java_version + "/java_toolchain_default.bzl"],
651-
cmd = "cp $< $@",
652-
),
653-
]
654-
for java_version in JAVA_VERSIONS
655-
]
646+
# Following targets build java_tools_prebuilt.zip part of java_tools
647+
# It is painstainkingly built by renaming single files, zipping them and merging zips together
648+
# TODO(bazel-team): Replace this with a single target, for example "release_archive" in rules_kotlin
649+
genrule(
650+
name = "java_tools_prebuilt_build_zip",
651+
srcs = ["//tools/jdk:BUILD.java_tools_prebuilt"],
652+
outs = ["java_tools_prebuilt_build.zip"],
653+
cmd = "cat $(SRCS) > BUILD; zip -qjX $@ BUILD",
654+
)
656655

657-
[
658-
genrule(
659-
name = "java_tools_java" + java_version + "_build_zip",
660-
srcs = [
661-
"remote_java_tools_java" + java_version + "/BUILD",
662-
"remote_java_tools_java" + java_version + "/java_toolchain_default.bzl",
663-
],
664-
outs = ["java_tools_java_" + java_version + "_build.zip"],
665-
cmd = "zip -qjX $@ $(SRCS)",
666-
)
667-
for java_version in JAVA_VERSIONS
668-
]
656+
genrule(
657+
name = "java_tools_prebuilt_no_build_zip",
658+
srcs = [
659+
"//src/tools/singlejar:singlejar_deploy_zip",
660+
"//third_party/ijar:ijar_deploy_zip",
661+
],
662+
outs = ["java_tools_prebuilt_no_build.zip"],
663+
cmd = "$(location //src:merge_zip_files) java_tools $@ $(SRCS)",
664+
output_to_bindir = True,
665+
tools = ["//src:merge_zip_files"],
666+
visibility = ["//src/test/shell/bazel:__pkg__"],
667+
)
669668

670-
# Builds the remote Java tools archive. Not embedded or used in Bazel, but used
671-
# by the Java tools release process.
672-
[
673-
genrule(
674-
name = "java_tools_java" + java_version + "_no_build_zip",
675-
srcs = [
676-
":jars_java_tools_java" + java_version + ".zip",
677-
"//src/tools/singlejar:singlejar_transitive_zip",
678-
"//third_party/ijar:ijar_transitive_zip",
679-
"//third_party/java/jacoco:jacoco_jars_zip",
680-
"//third_party/java/proguard:proguard_zip",
681-
],
682-
outs = ["java_tools_java" + java_version + "_no_build.zip"],
683-
cmd = "$(location //src:merge_zip_files) java_tools $@ $(SRCS)",
684-
output_to_bindir = 1,
685-
tools = ["//src:merge_zip_files"],
686-
visibility = ["//src/test/shell/bazel:__pkg__"],
687-
)
688-
for java_version in JAVA_VERSIONS
689-
]
669+
genrule(
670+
name = "java_tools_prebuilt_zip",
671+
srcs = [
672+
"java_tools_prebuilt_no_build.zip",
673+
"java_tools_prebuilt_build.zip",
674+
],
675+
outs = ["java_tools_prebuilt.zip"],
676+
cmd = "$(location //src:merge_zip_files) - $@ $(SRCS)",
677+
output_to_bindir = 1,
678+
tools = ["//src:merge_zip_files"],
679+
visibility = ["//src/test/shell/bazel:__pkg__"],
680+
)
690681

691-
[
692-
genrule(
693-
name = "java_tools_java" + java_version + "_zip",
694-
srcs = [
695-
"java_tools_java" + java_version + "_no_build.zip",
696-
"java_tools_java_" + java_version + "_build.zip",
697-
],
698-
outs = ["java_tools_java" + java_version + ".zip"],
699-
cmd = "$(location //src:merge_zip_files) - $@ $(SRCS)",
700-
output_to_bindir = 1,
701-
tools = ["//src:merge_zip_files"],
702-
visibility = ["//src/test/shell/bazel:__pkg__"],
703-
)
704-
for java_version in JAVA_VERSIONS
705-
]
682+
# Following targets used by the java_tools_binaries Buildkite pipeline to upload
683+
# the java_tools_*.zip to either tmp/sources or tmp/build directories in GCS.
684+
sh_binary(
685+
name = "upload_java_tools_dist",
686+
srcs = ["upload_java_tools.sh"],
687+
args = [
688+
"--java_tools_zip",
689+
"src/java_tools_dist.zip",
690+
"--gcs_java_tools_dir",
691+
"tmp/sources",
692+
],
693+
data = [":java_tools_dist"],
694+
deps = ["@bazel_tools//tools/bash/runfiles"],
695+
)
706696

707-
[
708-
# Targets used by the java_tools_binaries Buildkite pipeline to build the
709-
# java_tools_java* zips and upload them to a tmp directory in GCS.
710-
sh_binary(
711-
name = "upload_java_tools_java" + java_version,
712-
srcs = ["upload_java_tools.sh"],
713-
args = [
714-
"--gcs_java_tools_dir",
715-
"tmp/build",
716-
"--java_version",
717-
java_version,
718-
"--platform",
719-
] + select({
720-
"//src/conditions:darwin": ["darwin"],
721-
"//src/conditions:windows": ["windows"],
722-
"//src/conditions:linux": ["linux"],
723-
"//conditions:default": ["unknown"],
724-
}),
725-
data = [":java_tools_java" + java_version + "_zip"],
726-
deps = ["@bazel_tools//tools/bash/runfiles"],
727-
)
728-
for java_version in JAVA_VERSIONS
729-
]
697+
sh_binary(
698+
name = "upload_java_tools",
699+
srcs = ["upload_java_tools.sh"],
700+
args = [
701+
"--java_tools_zip",
702+
"src/java_tools.zip",
703+
"--gcs_java_tools_dir",
704+
"tmp/build",
705+
],
706+
data = [":java_tools_zip"],
707+
deps = ["@bazel_tools//tools/bash/runfiles"],
708+
)
709+
710+
sh_binary(
711+
name = "upload_java_tools_prebuilt",
712+
srcs = ["upload_java_tools.sh"],
713+
args = [
714+
"--java_tools_zip",
715+
"src/java_tools_prebuilt.zip",
716+
"--gcs_java_tools_dir",
717+
"tmp/build",
718+
"--platform",
719+
] + select({
720+
"//src/conditions:darwin": ["darwin"],
721+
"//src/conditions:windows": ["windows"],
722+
"//src/conditions:linux": ["linux"],
723+
"//conditions:default": ["unknown"],
724+
}),
725+
data = [":java_tools_prebuilt_zip"],
726+
deps = ["@bazel_tools//tools/bash/runfiles"],
727+
)
730728

731729
# Part of the Java tools remote archive. Not embedded or used in Bazel.
732730
genrule(

0 commit comments

Comments
 (0)