diff options
Diffstat (limited to 'src/main/java/com/google/devtools')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/android/AndroidDataConverter.java | 6 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/android/RClassGeneratorActionBuilder.java | 14 |
2 files changed, 16 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDataConverter.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDataConverter.java index 33cc657d1a..bafc0a85b2 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDataConverter.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDataConverter.java @@ -108,6 +108,12 @@ public class AndroidDataConverter<T> extends ParametrizedMapFn<T> { .collect(Collectors.joining(joinerType.itemSeparator)); } + /** + * Creates a builder for a new {@link AndroidDataConverter}. + * + * <p>Because of how Bazel handles these objects, call this method *only* as part of creating a + * static final field. + */ public static <T> Builder<T> builder(JoinerType joinerType) { return new Builder<>(joinerType); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/RClassGeneratorActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/android/RClassGeneratorActionBuilder.java index 01dc6f549b..849881297c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/RClassGeneratorActionBuilder.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/RClassGeneratorActionBuilder.java @@ -33,6 +33,15 @@ import java.util.function.Function; /** Builds up the spawn action for $android_rclass_generator. */ public class RClassGeneratorActionBuilder { + private static final AndroidDataConverter<ValidatedAndroidData> AAPT_CONVERTER = + AndroidDataConverter.<ValidatedAndroidData>builder(JoinerType.COLON_COMMA) + .with(chooseDepsToArg(AndroidAaptVersion.AAPT)) + .build(); + private static final AndroidDataConverter<ValidatedAndroidData> AAPT2_CONVERTER = + AndroidDataConverter.<ValidatedAndroidData>builder(JoinerType.COLON_COMMA) + .with(chooseDepsToArg(AndroidAaptVersion.AAPT2)) + .build(); + private final RuleContext ruleContext; private ResourceDependencies dependencies; @@ -98,10 +107,7 @@ public class RClassGeneratorActionBuilder { builder.addAll( VectorArg.addBefore("--library") .each(dependencies.getResourceContainers()) - .mapped( - AndroidDataConverter.<ValidatedAndroidData>builder(JoinerType.COLON_COMMA) - .with(chooseDepsToArg(version)) - .build())); + .mapped(version == AndroidAaptVersion.AAPT2 ? AAPT2_CONVERTER : AAPT_CONVERTER)); if (version == AndroidAaptVersion.AAPT2) { inputs.addTransitive(dependencies.getTransitiveAapt2RTxt()); } else { |