diff --git a/BUILD b/BUILD index 4c0a0198b48ef5..43df79b2320f69 100644 --- a/BUILD +++ b/BUILD @@ -165,9 +165,8 @@ filegroup( srcs = [ "//src/main/java/com/google/devtools/build/lib/bazel/rules:builtins_bzl.zip", "//src/main/java/com/google/devtools/build/lib/bazel/rules:coverage.WORKSPACE", - "//src/main/java/com/google/devtools/build/lib/bazel/rules:rules_license.WORKSPACE", + "//src/main/java/com/google/devtools/build/lib/bazel/rules:rules_suffix.WORKSPACE", "//src/main/java/com/google/devtools/build/lib/bazel/rules/cpp:cc_configure.WORKSPACE", - "//src/main/java/com/google/devtools/build/lib/bazel/rules/java:jdk.WORKSPACE", ], ) @@ -198,17 +197,6 @@ pkg_tar( visibility = ["//:__subpackages__"], ) -pkg_tar( - name = "rules_java-srcs", - srcs = ["@rules_java//:distribution"], - remap_paths = { - "external/": "", - "../": "", - }, - strip_prefix = ".", - visibility = ["//:__subpackages__"], -) - write_file( name = "gen_maven_repo_name", out = "MAVEN_CANONICAL_REPO_NAME", @@ -263,7 +251,6 @@ genrule( ":bazel-srcs", ":bootstrap-jars", ":platforms-srcs", - ":rules_java-srcs", ":maven-srcs", "//src:derived_java_srcs", "@bootstrap_repo_cache//:archives.tar", diff --git a/src/BUILD b/src/BUILD index 68a4e7630a2ce4..433d7ac86b7106 100644 --- a/src/BUILD +++ b/src/BUILD @@ -27,7 +27,6 @@ md5_cmd = "set -e -o pipefail && %s $(SRCS) | %s | %s > $@" "//src/main/tools:linux-sandbox", "//tools/osx:xcode-locator", "//:platforms-srcs", - "//:rules_java-srcs", ] + select({ "//src/conditions:windows": [], "//conditions:default": [ @@ -248,7 +247,6 @@ genrule( "//src/main/java/com/google/devtools/build/lib/bazel:BazelServer_deploy.jar", "install_base_key" + suffix, "//:platforms-srcs", - "//:rules_java-srcs", # Non-ordered items follow: "//src/main/java/net/starlark/java/eval:cpu_profiler", "//src/main/tools:build-runfiles", diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/BUILD b/src/main/java/com/google/devtools/build/lib/bazel/rules/BUILD index 0e29f4fed9a1a1..089243d8e4fa53 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BUILD +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BUILD @@ -27,7 +27,7 @@ java_library( "xcode_configure.WORKSPACE", ":builtins_bzl_zip", ":coverage.WORKSPACE", - ":rules_license.WORKSPACE", + ":rules_suffix.WORKSPACE", ], deps = [ "//src/main/java/com/google/devtools/build/lib:runtime", @@ -132,13 +132,25 @@ gen_workspace_stanza( ) gen_workspace_stanza( - name = "rules_license", - out = "rules_license.WORKSPACE", + name = "rules_suffix", + out = "rules_suffix.WORKSPACE", + postamble = """ + load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains") + rules_java_dependencies() + rules_java_toolchains() + """, preamble = """ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") """, - repos = ["rules_license"], + repos = [ + "bazel_skylib", # Dependency of other rules + "rules_java", # For auto-load java rules symbols + "rules_cc", # For auto-load cc rules symbols + "rules_python", # For auto-load python rules symbols + "rules_license", # for license attestations + "rules_proto", + ], use_maybe = 1, visibility = ["//:__pkg__"], ) diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRulesModule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRulesModule.java index f068555386f37e..879a792981bd70 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRulesModule.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRulesModule.java @@ -559,11 +559,8 @@ public void initializeRuleClasses(ConfiguredRuleClassProvider.Builder builder) { ResourceFileLoader.loadResource(BazelRulesModule.class, "xcode_configure.WORKSPACE")); builder.addWorkspaceFileSuffix( ResourceFileLoader.loadResource(BazelShRuleClasses.class, "sh_configure.WORKSPACE")); - - // Load rules_license, which is needed for license attestations for many rules, including - // things in @bazel_tools builder.addWorkspaceFileSuffix( - ResourceFileLoader.loadResource(BazelRulesModule.class, "rules_license.WORKSPACE")); + ResourceFileLoader.loadResource(BazelRulesModule.class, "rules_suffix.WORKSPACE")); } catch (IOException e) { throw new IllegalStateException(e); } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/JavaRules.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/JavaRules.java index b95984478f4af1..373ff25b13af6d 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/JavaRules.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/JavaRules.java @@ -78,11 +78,6 @@ public void init(ConfiguredRuleClassProvider.Builder builder) { EXPERIMENTAL_JAVA_LIBRARY_EXPORT, Starlark.NONE)); try { - builder.addWorkspaceFilePrefix( - ResourceFileLoader.loadResource( - BazelJavaRuleClasses.class, "rules_java_builtin.WORKSPACE")); - builder.addWorkspaceFileSuffix( - ResourceFileLoader.loadResource(BazelJavaRuleClasses.class, "jdk.WORKSPACE")); builder.addWorkspaceFileSuffix( ResourceFileLoader.loadResource(JavaRules.class, "coverage.WORKSPACE")); } catch (IOException e) { diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BUILD b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BUILD index 90d2ffd5f69fa8..826e0b3308ceb4 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BUILD +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BUILD @@ -1,5 +1,4 @@ load("@rules_java//java:defs.bzl", "java_library") -load("//:workspace_deps.bzl", "gen_workspace_stanza") package( default_applicable_licenses = ["//:license"], @@ -24,10 +23,7 @@ java_library( [ "*.txt", ], - ) + [ - ":jdk.WORKSPACE", - ":rules_java_builtin.WORKSPACE", - ], + ), deps = [ "//src/main/java/com/google/devtools/build/lib/analysis:analysis_cluster", "//src/main/java/com/google/devtools/build/lib/analysis:config/execution_transition_factory", @@ -67,23 +63,3 @@ java_library( "//third_party:jsr305", ], ) - -gen_workspace_stanza( - name = "workspace_with_java_toolchains", - out = "jdk.WORKSPACE", - repo_clause = """ - name = "{repo}", - sha256 = "{sha256}", - strip_prefix = {strip_prefix}, - urls = {urls}, - """, - repos = [ - "bazel_skylib", - "rules_cc", - "rules_java", - "rules_proto", - "rules_python", - ], - template = "jdk.WORKSPACE.tmpl", - visibility = ["//:__pkg__"], -) diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.tmpl b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.tmpl deleted file mode 100644 index dc4753b282e95a..00000000000000 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.tmpl +++ /dev/null @@ -1,45 +0,0 @@ -# External dependencies for the java_* rules. -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") - -maybe( - http_archive, -{bazel_skylib} -) - -maybe( - http_archive, -{rules_java} -) - -# Needed only because of java_tools. -maybe( - http_archive, -{rules_cc} -) - -# Needed only because of java_tools. -maybe( - http_archive, -{rules_proto} -) - -# Needed only because of proguard_allowlister in java_tools. -maybe( - http_archive, -{rules_python} -) - -load("@rules_java_builtin//toolchains:local_java_repository.bzl", "local_java_repository") -load("@rules_java_builtin//toolchains:jdk_build_file.bzl", "JDK_BUILD_TEMPLATE") -# Override local_jdk repo to add repo_mapping for rules_java -maybe( - local_java_repository, - name = "local_jdk", - build_file_content = JDK_BUILD_TEMPLATE, - repo_mapping = {"@rules_java" : "@rules_java_builtin"}, -) - -load("@rules_java_builtin//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains") -rules_java_dependencies() -rules_java_toolchains() diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/rules_java_builtin.WORKSPACE b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/rules_java_builtin.WORKSPACE deleted file mode 100644 index e2a1b2e0ecd254..00000000000000 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/rules_java_builtin.WORKSPACE +++ /dev/null @@ -1,6 +0,0 @@ -load("@bazel_tools//tools/build_defs/repo:local.bzl", rules_java_builtin_local_repository = "local_repository") -rules_java_builtin_local_repository( - name = "rules_java_builtin", - path = __embedded_dir__ + "/rules_java", - repo_mapping = {"@rules_java" : "@rules_java_builtin"} -) diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/tools.WORKSPACE b/src/main/java/com/google/devtools/build/lib/bazel/rules/tools.WORKSPACE index bbbde6ec9acaa9..9130f13aba4085 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/tools.WORKSPACE +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/tools.WORKSPACE @@ -1,7 +1,6 @@ local_repository( name = "bazel_tools", path = __embedded_dir__ + "/embedded_tools", - repo_mapping = {"@rules_java" : "@rules_java_builtin"} ) bind( diff --git a/src/package-bazel.sh b/src/package-bazel.sh index 32b762f6985244..10bb651da2b12e 100755 --- a/src/package-bazel.sh +++ b/src/package-bazel.sh @@ -25,7 +25,6 @@ EMBEDDED_TOOLS=$1; shift DEPLOY_JAR=$1; shift INSTALL_BASE_KEY=$1; shift PLATFORMS_ARCHIVE=$1; shift -RULES_JAVA_ARCHIVE=$1; shift if [[ "$OUT" == *jdk_allmodules.zip ]]; then DEV_BUILD=1 @@ -79,18 +78,6 @@ fi # "platforms" is a well-known module, so no need to tamper with anything here. ) -( - cd $PACKAGE_DIR - tar -xf $WORKDIR/$RULES_JAVA_ARCHIVE -C . - # Rename "rules_java~" or "rules_java+" to "rules_java". - if [[ -d rules_java~ ]]; then - mv rules_java~ rules_java - fi - if [[ -d rules_java+ ]]; then - mv rules_java+ rules_java - fi -) - # Make a list of the files in the order we want them inside the final zip. ( cd $PACKAGE_DIR