Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use java macros in java_tools. #8758

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,13 @@ JAVA_VERSIONS = ("9", "10", "11", "12")
for java_version in JAVA_VERSIONS
]

genrule(
name = "create_java_tools_workspace_file_zip",
srcs = ["//tools/jdk:WORKSPACE.java_tools"],
outs = ["java_tools_workspace.zip"],
cmd = "cp $< WORKSPACE && zip -jX $@ WORKSPACE",
)

[
genrule(
name = "java_tools_java" + java_version + "_build_zip",
Expand Down Expand Up @@ -687,6 +694,7 @@ JAVA_VERSIONS = ("9", "10", "11", "12")
srcs = [
"java_tools_java" + java_version + "_no_build.zip",
"java_tools_java_" + java_version + "_build.zip",
":java_tools_workspace.zip"
],
outs = ["java_tools_java" + java_version + ".zip"],
cmd = "$(location //src:merge_zip_files) - $@ $(SRCS)",
Expand Down
22 changes: 22 additions & 0 deletions src/test/shell/bazel/bazel_java_tools_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,26 @@ function test_java_tools_has_proguard() {
expect_path_in_java_tools "java_tools/third_party/java/proguard/GPL.html"
}

function test_java_tools_toolchain_builds() {
local java_tools_rlocation=$(rlocation io_bazel/src/java_tools_${JAVA_TOOLS_JAVA_VERSION}.zip)
local java_tools_zip_file_url="file://${java_tools_rlocation}"
if "$is_windows"; then
java_tools_zip_file_url="file:///${java_tools_rlocation}"
fi
cat >WORKSPACE <<EOF
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "local_java_tools",
urls = ["${java_tools_zip_file_url}"]
)
http_archive(
name = "rules_java",
sha256 = "bc81f1ba47ef5cc68ad32225c3d0e70b8c6f6077663835438da8d5733f917598",
urls = ["https://github.com/bazelbuild/rules_java/archive/7cf3cefd652008d0a64a419c34c13bdca6c8f178.zip"],
strip_prefix = "rules_java-7cf3cefd652008d0a64a419c34c13bdca6c8f178"
)
EOF
bazel build @local_java_tools//:toolchain || fail "toolchain failed to build"
}

run_suite "Java tools archive tests"
7 changes: 7 additions & 0 deletions src/test/shell/bazel/testdata/jdk_http_archives
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,10 @@ http_archive(
"https://mirror.bazel.build/openjdk/azul-zulu12.2.3-ca-jdk12.0.1/zulu12.2.3-ca-jdk12.0.1-win_x64.zip",
],
)

http_archive(
name = "rules_java",
sha256 = "bc81f1ba47ef5cc68ad32225c3d0e70b8c6f6077663835438da8d5733f917598",
urls = ["https://github.com/bazelbuild/rules_java/archive/7cf3cefd652008d0a64a419c34c13bdca6c8f178.zip"],
strip_prefix = "rules_java-7cf3cefd652008d0a64a419c34c13bdca6c8f178"
)
3 changes: 2 additions & 1 deletion tools/jdk/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ remote_java_tools_filegroup(
target = ":singlejar",
)

exports_files(["BUILD.java_tools"])
exports_files(["BUILD.java_tools", "WORKSPACE.java_tools"])

remote_java_tools_filegroup(
name = "genclass",
Expand Down Expand Up @@ -403,6 +403,7 @@ filegroup(
"proguard_whitelister_test_input.cfg",
"remote_java_tools_aliases.bzl",
"toolchain_utils.bzl",
"WORKSPACE.java_tools"
],
)

Expand Down
2 changes: 2 additions & 0 deletions tools/jdk/BUILD.java_tools
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package(default_visibility = ["//visibility:public"])

licenses(["notice"]) # Apache 2.0

load("@rules_java//java:defs.bzl", "java_toolchain", "java_import", "java_binary")

java_toolchain(
name = "toolchain",
bootclasspath = ["@bazel_tools//tools/jdk:platformclasspath"],
Expand Down
8 changes: 8 additions & 0 deletions tools/jdk/WORKSPACE.java_tools
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's jdk.WORKSPACE for and what's WORKSPACE.java_tools for? Do we need both of them to define rules_java?

name = "rules_java",
sha256 = "bc81f1ba47ef5cc68ad32225c3d0e70b8c6f6077663835438da8d5733f917598",
urls = ["https://github.com/bazelbuild/rules_java/archive/7cf3cefd652008d0a64a419c34c13bdca6c8f178.zip"],
strip_prefix = "rules_java-7cf3cefd652008d0a64a419c34c13bdca6c8f178"
)