aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/android/java/com/google/devtools/build/android/AndroidResourceMerger.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/AndroidResourceMerger.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/AndroidResourceMerger.java')
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/AndroidResourceMerger.java32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/AndroidResourceMerger.java b/src/tools/android/java/com/google/devtools/build/android/AndroidResourceMerger.java
index 8fc6075382..eb7fd70711 100644
--- a/src/tools/android/java/com/google/devtools/build/android/AndroidResourceMerger.java
+++ b/src/tools/android/java/com/google/devtools/build/android/AndroidResourceMerger.java
@@ -64,8 +64,8 @@ public class AndroidResourceMerger {
final VariantType type,
@Nullable final Path symbolsOut,
@Nullable AndroidResourceClassWriter rclassWriter,
- AndroidDataDeserializer deserializer)
- throws MergingException {
+ AndroidDataDeserializer deserializer,
+ boolean throwOnResourceConflict) {
Stopwatch timer = Stopwatch.createStarted();
final ListeningExecutorService executorService =
MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(15));
@@ -78,7 +78,8 @@ public class AndroidResourceMerger {
primary,
primaryManifest,
type != VariantType.LIBRARY,
- deserializer);
+ deserializer,
+ throwOnResourceConflict);
timer.reset().start();
if (symbolsOut != null) {
AndroidDataSerializer serializer = AndroidDataSerializer.create();
@@ -114,14 +115,19 @@ public class AndroidResourceMerger {
ParsedAndroidData primary,
Path primaryManifest,
boolean allowPrimaryOverrideAll,
- AndroidDataDeserializer deserializer)
- throws MergingException {
+ AndroidDataDeserializer deserializer,
+ boolean throwOnResourceConflict) {
Stopwatch timer = Stopwatch.createStarted();
try {
AndroidDataMerger merger =
AndroidDataMerger.createWithPathDeduplictor(executorService, deserializer);
return merger.loadAndMerge(
- transitive, direct, primary, primaryManifest, allowPrimaryOverrideAll);
+ transitive,
+ direct,
+ primary,
+ primaryManifest,
+ allowPrimaryOverrideAll,
+ throwOnResourceConflict);
} finally {
logger.fine(String.format("merge finished in %sms", timer.elapsed(TimeUnit.MILLISECONDS)));
}
@@ -140,8 +146,8 @@ public class AndroidResourceMerger {
@Nullable final PngCruncher cruncher,
final VariantType type,
@Nullable final Path symbolsOut,
- final List<String> filteredResources)
- throws MergingException {
+ final List<String> filteredResources,
+ boolean throwOnResourceConflict) {
try {
final ParsedAndroidData parsedPrimary = ParsedAndroidData.from(primary);
return mergeData(
@@ -155,7 +161,8 @@ public class AndroidResourceMerger {
type,
symbolsOut,
null /* rclassWriter */,
- AndroidDataDeserializer.withFilteredResources(filteredResources));
+ AndroidDataDeserializer.withFilteredResources(filteredResources),
+ throwOnResourceConflict);
} catch (IOException e) {
throw MergingException.wrapException(e);
}
@@ -175,8 +182,8 @@ public class AndroidResourceMerger {
@Nullable final PngCruncher cruncher,
final VariantType type,
@Nullable final Path symbolsOut,
- @Nullable final AndroidResourceClassWriter rclassWriter)
- throws MergingException {
+ @Nullable final AndroidResourceClassWriter rclassWriter,
+ boolean throwOnResourceConflict) {
final ParsedAndroidData.Builder primaryBuilder = ParsedAndroidData.Builder.newBuilder();
final AndroidDataDeserializer deserializer = AndroidDataDeserializer.create();
primary.deserialize(deserializer, primaryBuilder.consumers());
@@ -192,7 +199,8 @@ public class AndroidResourceMerger {
type,
symbolsOut,
rclassWriter,
- deserializer);
+ deserializer,
+ throwOnResourceConflict);
}
}