Add option --break_build_on_parallel_dex2oat_failure.
Right now dex2oat action failures are not treated as such, instead the action
always succeeds and dex2oat is delayed until test runtime. This has the effect
of hiding real issues and making tests flaky. Initially add option to break the
build in order to understand the scope of the errors.
RELNOTES: add --break_build_on_parallel_dex2oat_failure to shortcut tests on dex2oat errors
PiperOrigin-RevId: 261228516
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java
index 8081498..1efa60e 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java
@@ -530,6 +530,17 @@
help = "Use dex2oat in parallel to possibly speed up android_test.")
public boolean useParallelDex2Oat;
+ @Option(
+ name = "break_build_on_parallel_dex2oat_failure",
+ defaultValue = "false",
+ documentationCategory = OptionDocumentationCategory.TESTING,
+ effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
+ metadataTags = {OptionMetadataTag.EXPERIMENTAL},
+ help =
+ "If true dex2oat action failures will cause the build to break "
+ + "instead of executing dex2oat during test runtime.")
+ public boolean breakBuildOnParallelDex2OatFailure;
+
// Do not use on the command line.
// This flag is intended to be updated as we add supported flags to the incremental dexing tools
@Option(
@@ -1083,6 +1094,7 @@
private final boolean useAapt2ForRobolectric;
private final boolean throwOnResourceConflict;
private final boolean useParallelDex2Oat;
+ private final boolean breakBuildOnParallelDex2OatFailure;
private final boolean omitResourcesInfoProviderFromAndroidBinary;
private final boolean fixedResourceNeverlinking;
private final AndroidRobolectricTestDeprecationLevel robolectricTestDeprecationLevel;
@@ -1132,6 +1144,7 @@
this.useAapt2ForRobolectric = options.useAapt2ForRobolectric;
this.throwOnResourceConflict = options.throwOnResourceConflict;
this.useParallelDex2Oat = options.useParallelDex2Oat;
+ this.breakBuildOnParallelDex2OatFailure = options.breakBuildOnParallelDex2OatFailure;
this.omitResourcesInfoProviderFromAndroidBinary =
options.omitResourcesInfoProviderFromAndroidBinary;
this.fixedResourceNeverlinking = options.fixedResourceNeverlinking;
@@ -1333,6 +1346,11 @@
}
@Override
+ public boolean breakBuildOnParallelDex2OatFailure() {
+ return breakBuildOnParallelDex2OatFailure;
+ }
+
+ @Override
public boolean compressJavaResources() {
return compressJavaResources;
}
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/android/AndroidConfigurationApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/android/AndroidConfigurationApi.java
index 6ff5994..4d9fb5e 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/android/AndroidConfigurationApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/android/AndroidConfigurationApi.java
@@ -146,6 +146,13 @@
boolean useParallelDex2Oat();
@SkylarkCallable(
+ name = "break_build_on_parallel_dex2oat_failure",
+ structField = true,
+ doc = "",
+ documented = false)
+ boolean breakBuildOnParallelDex2OatFailure();
+
+ @SkylarkCallable(
name = "compress_java_resources",
structField = true,
doc = "",