From bc1e9d85c97e8a62b49c6e26ede14eccd4951bd4 Mon Sep 17 00:00:00 2001 From: Googler Date: Thu, 22 Sep 2022 10:30:17 -0700 Subject: [PATCH] Rollforward of https://github.com/bazelbuild/bazel/commit/e96507b5313eee3d7f69896a089bbb57165e7c23: Enable Starlark java_binary PiperOrigin-RevId: 476136813 Change-Id: I1b778832ed52fb732bae1ed4cd1b32ebd72720f8 --- .../devtools/build/lib/analysis/util/BuildViewTestCase.java | 1 + .../build/lib/rules/android/AndroidBuildViewTestCase.java | 2 +- .../devtools/build/lib/rules/java/JavaStarlarkApiTest.java | 6 +++++- .../build/lib/skyframe/ConfigurationsForTargetsTest.java | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java index 3e59ffb603b609..e9fd7e03d246f7 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java @@ -546,6 +546,7 @@ private static BuildLanguageOptions parseBuildLanguageOptions(String... options) throws Exception { OptionsParser parser = OptionsParser.builder().optionsClasses(BuildLanguageOptions.class).build(); + parser.parse("--experimental_google_legacy_api"); // For starlark java_binary; parser.parse(options); return parser.getOptions(BuildLanguageOptions.class); } diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBuildViewTestCase.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBuildViewTestCase.java index c80276e9b2a169..3e735a6d3397e8 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBuildViewTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBuildViewTestCase.java @@ -95,7 +95,7 @@ protected void useConfiguration(ImmutableMap starlarkOptions, St ImmutableList.Builder fullArgs = ImmutableList.builder(); fullArgs.add("--incompatible_enable_android_toolchain_resolution"); // Uncomment the below to get more info when tests fail because of toolchain resolution. - // fullArgs.add("--toolchain_resolution_debug=tools/android:.*toolchain_type"); + // fullArgs.add("--toolchain_resolution_debug=tools/android:.*toolchain_type"); boolean hasPlatform = false; for (String arg : args) { if (arg.startsWith("--android_sdk=")) { diff --git a/src/test/java/com/google/devtools/build/lib/rules/java/JavaStarlarkApiTest.java b/src/test/java/com/google/devtools/build/lib/rules/java/JavaStarlarkApiTest.java index de552809c86aba..b3bf78554bed98 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/java/JavaStarlarkApiTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/java/JavaStarlarkApiTest.java @@ -1615,12 +1615,14 @@ public void starlarkJavaToJavaBinaryAttributes() throws Exception { " deps = [':mya'], runtime_deps = [':myb'])"); assertNoEvents(); + setBuildLanguageOptions("--experimental_google_legacy_api"); // Test that all bottom jars are on the runtime classpath. ConfiguredTarget binary = getConfiguredTarget("//foo:binary"); assertThat( prettyArtifactNames( binary - .getProvider(JavaRuntimeClasspathProvider.class) + .get(JavaInfo.PROVIDER) + .getCompilationInfoProvider() .getRuntimeClasspath() .getSet(Artifact.class))) .containsAtLeast("foo/libjl_bottom_for_deps.jar", "foo/libjl_bottom_for_runtime_deps.jar"); @@ -1971,6 +1973,7 @@ public void javaBinary_propagatesDirectNativeLibrariesInJavaInfo() throws Except "my_rule(name = 'r', dep = ':jl', cc_dep = ':ccl')", "java_binary(name = 'binary', main_class = 'C', srcs = ['java/C.java'], deps = [':r'])"); + setBuildLanguageOptions("--experimental_google_legacy_api"); ConfiguredTarget testTarget = getConfiguredTarget("//foo:binary"); TemplateExpansionAction action = @@ -2218,6 +2221,7 @@ public void javaCommonCompileNeverlink() throws Exception { " fragments = ['java']", ")"); + setBuildLanguageOptions("--experimental_google_legacy_api"); ConfiguredTarget target = getConfiguredTarget("//java/test:plugin"); assertThat( actionsTestUtil() diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ConfigurationsForTargetsTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ConfigurationsForTargetsTest.java index 48a821fbc3cd5b..074e7375728563 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/ConfigurationsForTargetsTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/ConfigurationsForTargetsTest.java @@ -351,7 +351,7 @@ public void splitDeps() throws Exception { "java/a/BUILD", "cc_library(name = 'lib', srcs = ['lib.cc'])", "android_binary(name='a', manifest = 'AndroidManifest.xml', deps = [':lib'])"); - useConfiguration("--fat_apk_cpu=k8,armeabi-v7a"); + useConfiguration("--fat_apk_cpu=k8,armeabi-v7a", "--experimental_google_legacy_api"); List deps = getConfiguredDeps("//java/a:a", "deps"); assertThat(deps).hasSize(2); ConfiguredTarget dep1 = deps.get(0);