diff options
author | 2017-02-16 22:46:41 +0000 | |
---|---|---|
committer | 2017-02-17 14:53:19 +0000 | |
commit | edeb6d0ba47a52ddd9fc421f1ab577f4eafdc2b5 (patch) | |
tree | 0ec950dcde90cd663eae31ae9e01294a92fbceed /src/main/java/com/google/devtools/build/lib/rules | |
parent | 0d4980bc7251ebb62cbb85c7777da6fd4361dd21 (diff) |
Make Android data binding work with --experimental_use_parallel_android_resource_processing.
Without that flag, data binding already works via hooks in ApplicationManifest and
AndroidResourceProcessingAction.
The flag replaces AndroidResourceProcessingAction with three smaller processors:
AndroidResourceParsingAction, AndroidResourceMergingAction, and
AndroidResourceValidatorAction. So this change hooks the same logic into
AndroidResourceMergingAction (at the equivalent place where data binding
applies in the other pipeline).
We could alternatively hook this into AndroidResourceValidatorAction (i.e. anywhere
after resource merging completes and before aapt starts). But doing that would block
Java compilation on aapt finishing, which the whole point of the flag is to unblock.
--
PiperOrigin-RevId: 147770236
MOS_MIGRATED_REVID=147770236
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
2 files changed, 18 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourceMergingActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourceMergingActionBuilder.java index 1e3ae9ccce..3d7886d368 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourceMergingActionBuilder.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourceMergingActionBuilder.java @@ -61,6 +61,7 @@ public class AndroidResourceMergingActionBuilder { private Artifact mergedResourcesOut; private Artifact classJarOut; private Artifact manifestOut; + private Artifact dataBindingInfoZip; // Flags private String customJavaPackage; @@ -100,6 +101,16 @@ public class AndroidResourceMergingActionBuilder { return this; } + /** + * The output zip for resource-processed data binding expressions (i.e. a zip of .xml files). + * If null, data binding processing is skipped (and data binding expressions aren't allowed in + * layout resources). + */ + public AndroidResourceMergingActionBuilder setDataBindingInfoZip(Artifact zip) { + this.dataBindingInfoZip = zip; + return this; + } + public AndroidResourceMergingActionBuilder setJavaPackage(String customJavaPackage) { this.customJavaPackage = customJavaPackage; return this; @@ -156,6 +167,11 @@ public class AndroidResourceMergingActionBuilder { builder.add("--packageForR").add(customJavaPackage); } + if (dataBindingInfoZip != null) { + builder.addExecPath("--dataBindingInfoOut", dataBindingInfoZip); + outs.add(dataBindingInfoZip); + } + SpawnAction.Builder spawnActionBuilder = new SpawnAction.Builder(); // Create the spawn action. ruleContext.registerAction( diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/ApplicationManifest.java b/src/main/java/com/google/devtools/build/lib/rules/android/ApplicationManifest.java index 05c896a96f..019a85d8d7 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/ApplicationManifest.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/ApplicationManifest.java @@ -466,7 +466,8 @@ public final class ApplicationManifest { .withDependencies(resourceDeps) .setMergedResourcesOut(mergedResources) .setManifestOut(manifestOut) - .setClassJarOut(rJavaClassJar); + .setClassJarOut(rJavaClassJar) + .setDataBindingInfoZip(dataBindingInfoZip); ResourceContainer merged = resourcesMergerBuilder.build(ruleContext); AndroidResourceValidatorActionBuilder validatorBuilder = |