aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2017-07-13 19:50:00 +0200
committerGravatar László Csomor <laszlocsomor@google.com>2017-07-14 10:52:06 +0200
commit5abf4ed4dc9fc134e47f9b56e3b65ba26d0ba9f0 (patch)
treea046d265ae8c46d59150f849c15fc87fcc94f182 /src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java
parentfba07bb72570245d26bd8795709c5a004fc9026a (diff)
Add flag to turn Android resource merge conflicts from warnings into errors
RELNOTES: none PiperOrigin-RevId: 161831232
Diffstat (limited to 'src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java')
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java b/src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java
index 7a6947d698..16091348c1 100644
--- a/src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java
+++ b/src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java
@@ -19,6 +19,7 @@ import com.google.common.base.Joiner;
import com.google.common.base.Stopwatch;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Ordering;
+import com.google.devtools.build.android.AndroidDataMerger.MergeConflictException;
import com.google.devtools.build.android.AndroidResourceMerger.MergingException;
import com.google.devtools.build.android.Converters.ExistingPathConverter;
import com.google.devtools.build.android.Converters.PathConverter;
@@ -124,6 +125,14 @@ public class AarGeneratorAction {
help = "Path to write the archive."
)
public Path aarOutput;
+
+ @Option(name = "throwOnResourceConflict",
+ defaultValue = "false",
+ category = "config",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.UNKNOWN},
+ help = "If passed, resource merge conflicts will be treated as errors instead of warnings")
+ public boolean throwOnResourceConflict;
}
public static void main(String[] args) {
@@ -153,12 +162,17 @@ public class AarGeneratorAction {
null,
VariantType.LIBRARY,
null,
- /* filteredResources= */ ImmutableList.<String>of());
+ /* filteredResources= */ ImmutableList.<String>of(),
+ options.throwOnResourceConflict
+ );
logger.fine(String.format("Merging finished at %dms", timer.elapsed(TimeUnit.MILLISECONDS)));
writeAar(options.aarOutput, mergedData, options.manifest, options.rtxt, options.classes);
logger.fine(
String.format("Packaging finished at %dms", timer.elapsed(TimeUnit.MILLISECONDS)));
+ } catch (MergeConflictException e) {
+ logger.log(Level.SEVERE, e.getMessage());
+ System.exit(1);
} catch (IOException | MergingException e) {
logger.log(Level.SEVERE, "Error during merging resources", e);
System.exit(1);