Skip to content

Commit fa161fa

Browse files
jincopybara-github
authored andcommitted
Bubble aapt2 compile and link errors to Bazel
Previously, if there were any errors from the aapt2 compile and link steps, the resource processor will silently swallow them in the `try` block without a catch. This change adds a catch block to log and rethrow the error. RELNOTES: Fix an issue where the Android resource processor did not surface errors from aapt2 compile and link actions. Closes #7820. PiperOrigin-RevId: 240415485
1 parent 52d9f3b commit fa161fa

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/tools/android/java/com/google/devtools/build/android/ValidateAndLinkResourcesAction.java

+9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
// Copyright 2017 The Bazel Authors. All rights reserved.
1515
package com.google.devtools.build.android;
1616

17+
import static java.util.logging.Level.SEVERE;
18+
1719
import com.google.common.base.Preconditions;
1820
import com.google.devtools.build.android.aapt2.Aapt2ConfigOptions;
1921
import com.google.devtools.build.android.aapt2.CompiledResources;
@@ -29,6 +31,7 @@
2931
import java.nio.file.Path;
3032
import java.util.List;
3133
import java.util.Optional;
34+
import java.util.logging.Logger;
3235
import java.util.stream.Collectors;
3336

3437
/** Performs resource validation and static linking for compiled android resources. */
@@ -145,6 +148,9 @@ public static class Options extends OptionsBase {
145148
public Path sourceJarOut;
146149
}
147150

151+
private static final Logger logger =
152+
Logger.getLogger(ValidateAndLinkResourcesAction.class.getName());
153+
148154
public static void main(String[] args) throws Exception {
149155
final OptionsParser optionsParser =
150156
OptionsParser.newOptionsParser(Options.class, Aapt2ConfigOptions.class);
@@ -190,6 +196,9 @@ public static void main(String[] args) throws Exception {
190196
.copySourceJarTo(options.sourceJarOut)
191197
.copyRTxtTo(options.rTxtOut);
192198
profiler.recordEndOf("link");
199+
} catch (Exception e) {
200+
logger.log(SEVERE, "Error while validating and linking resources", e);
201+
throw e;
193202
}
194203
}
195204
}

0 commit comments

Comments
 (0)