From 41fd5e402f4d17db920e7ef281e2291f55cd6203 Mon Sep 17 00:00:00 2001 From: Romain Jobredeaux Date: Fri, 27 Aug 2021 15:59:39 +0000 Subject: [PATCH] Set --noautodetect_server_javabase in mixed build bazel. If a valid JAVA_HOME is set in the environment when running bazel with --experimental_repository_disable_download, bazel will unsuccessfully attempt to download rules_java. The above flag has the practical effect of preventing the download attempt (some clues as to why in the doc at go/aosp-bazel-jdk). Note that this also prevents building java targets in mixed mode. Eventually, we will pull in the java_rules into AOSP so they don't need to be downloaded. Test: build/bazel/ci/mixed_libc.sh Change-Id: Icdb186c18a3334f4caa17243a8620a1cc8c1db0e --- android/bazel_handler.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/android/bazel_handler.go b/android/bazel_handler.go index 40a5a7378..9c922dda4 100644 --- a/android/bazel_handler.go +++ b/android/bazel_handler.go @@ -353,7 +353,16 @@ type builtinBazelRunner struct{} // the invocation returned an error code. func (r *builtinBazelRunner) issueBazelCommand(paths *bazelPaths, runName bazel.RunName, command bazelCommand, extraFlags ...string) (string, string, error) { - cmdFlags := []string{"--output_base=" + absolutePath(paths.outputBase), command.command} + cmdFlags := []string{ + // --noautodetect_server_javabase has the practical consequence of preventing Bazel from + // attempting to download rules_java, which is incompatible with + // --experimental_repository_disable_download set further below. + // rules_java is also not needed until mixed builds start building java targets. + // TODO(b/197958133): Once rules_java is pulled into AOSP, remove this flag. + "--noautodetect_server_javabase", + "--output_base=" + absolutePath(paths.outputBase), + command.command, + } cmdFlags = append(cmdFlags, command.expression) cmdFlags = append(cmdFlags, "--profile="+shared.BazelMetricsFilename(paths, runName))