Embed rules_java in bazel
This change avoids downloading rules_java for serving rules_java_builtin, which makes https://github.com/bazelbuild/bazel/commit/3029a7db8a877e8a616b2ebe304573fae9ea9962 not an incompatible change for users's offline build.
Closes #18693.
PiperOrigin-RevId: 541584883
Change-Id: I4a9a5df19bbeb4885d27cfafc4daf50b469b8a6d
diff --git a/src/package-bazel.sh b/src/package-bazel.sh
index c69ac94..b88f257 100755
--- a/src/package-bazel.sh
+++ b/src/package-bazel.sh
@@ -25,6 +25,7 @@
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
@@ -71,26 +72,22 @@
(cd ${PACKAGE_DIR}/embedded_tools && unzip -q "${WORKDIR}/${EMBEDDED_TOOLS}")
fi
-# Unzip platforms.zip into platforms/, move files up from external/platforms
-# subdirectory if required, and create WORKSPACE if it doesn't exist.
(
cd $PACKAGE_DIR
- unzip -q -d platforms $WORKDIR/$PLATFORMS_ARCHIVE
- cd platforms
- # Platform files may be located under external/platform or platform depending
- # on the external repository source layout. Take them out if it's the case.
- # Note that, when enabling Bzlmod, the canonical repo name for platforms is platforms.<version>,
- # therefore, we use wildcard (platform*) to make sure it always work.
- if ls external/platforms*/ >/dev/null 2>&1; then
- # --experimental_sibling_repository_layout=false
- mv external/platforms*/* .
- rmdir -p external/platforms*
- else
- # --experimental_sibling_repository_layout=true
- mv platforms*/* .
- rmdir -p platforms*
+ tar -xf $WORKDIR/$PLATFORMS_ARCHIVE -C .
+ # Rename "platforms~<version>" to "platforms" in case of Bzlmod is enabled.
+ if [[ $(find . -maxdepth 1 -type d -name "platforms~*" | wc -l) -eq 1 ]]; then
+ mv platforms~* platforms
fi
- >> WORKSPACE
+)
+
+(
+ cd $PACKAGE_DIR
+ tar -xf $WORKDIR/$RULES_JAVA_ARCHIVE -C .
+ # Rename "rules_java~<version>" to "rules_java" in case of Bzlmod is enabled.
+ if [[ $(find . -maxdepth 1 -type d -name "rules_java~*" | wc -l) -eq 1 ]]; then
+ mv rules_java~* rules_java
+ fi
)
# Make a list of the files in the order we want them inside the final zip.