aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-09-28 00:12:20 +0000
committerGravatar Yun Peng <pcloudy@google.com>2016-09-28 08:29:12 +0000
commit105bb3f0b84d399b24e67860d3c7a4848803161f (patch)
treef76c7258745f5fd5130168f00cffc0a33caeabd2 /src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
parent68e555155a65f54306b58747dda8b87d021178c7 (diff)
Read android binary attributes that are queried for incremental dexing artifacts from AndroidSemantics.
-- MOS_MIGRATED_REVID=134475699
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
index a30885b296..f10004d08f 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
@@ -1109,7 +1109,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory {
Artifact classesDex = getDxArtifact(ruleContext, "classes.dex.zip");
Artifact jarToDex = getDxArtifact(ruleContext, "classes.jar");
createShuffleJarAction(ruleContext, true, (Artifact) null, ImmutableList.of(jarToDex),
- common, inclusionFilterJar, dexopts, attributes, (Artifact) null);
+ common, inclusionFilterJar, dexopts, androidSemantics, attributes, (Artifact) null);
createDexMergerAction(ruleContext, "off", jarToDex, classesDex, (Artifact) null, dexopts);
return new DexingOutput(classesDex, binaryJar, ImmutableList.of(classesDex));
} else {
@@ -1145,6 +1145,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory {
common,
inclusionFilterJar,
dexopts,
+ androidSemantics,
attributes,
mainDexList);
@@ -1192,7 +1193,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory {
if (incrementalDexing.contains(AndroidBinaryType.MULTIDEX_UNSHARDED)) {
Artifact jarToDex = AndroidBinary.getDxArtifact(ruleContext, "classes.jar");
createShuffleJarAction(ruleContext, true, (Artifact) null, ImmutableList.of(jarToDex),
- common, inclusionFilterJar, dexopts, attributes, (Artifact) null);
+ common, inclusionFilterJar, dexopts, androidSemantics, attributes, (Artifact) null);
createDexMergerAction(ruleContext, "minimal", jarToDex, classesDex, mainDexList, dexopts);
} else {
// Because the dexer also places resources into this zip, we also need to create a cleanup
@@ -1294,11 +1295,14 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory {
RuleContext ruleContext,
AndroidCommon common,
List<String> dexopts,
+ AndroidSemantics semantics,
JavaTargetAttributes attributes) {
- DexArchiveProvider.Builder result = new DexArchiveProvider.Builder()
- // Use providers from all attributes that declare DexArchiveAspect
- .addTransitiveProviders(
- ruleContext.getPrerequisites("deps", Mode.TARGET, DexArchiveProvider.class));
+ DexArchiveProvider.Builder result = new DexArchiveProvider.Builder();
+ for (String attr : semantics.getAttributesWithJavaRuntimeDeps(ruleContext)) {
+ // Use all available DexArchiveProviders from attributes that carry runtime dependencies
+ result.addTransitiveProviders(
+ ruleContext.getPrerequisites(attr, Mode.TARGET, DexArchiveProvider.class));
+ }
ImmutableSet<String> incrementalDexopts =
DexArchiveAspect.incrementalDexopts(ruleContext, dexopts);
for (Artifact jar : common.getJarsProducedForRuntime()) {
@@ -1340,6 +1344,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory {
AndroidCommon common,
@Nullable Artifact inclusionFilterJar,
List<String> dexopts,
+ AndroidSemantics semantics,
JavaTargetAttributes attributes,
@Nullable Artifact mainDexList)
throws InterruptedException {
@@ -1383,8 +1388,8 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory {
// Use dex archives instead of their corresponding Jars wherever we can. At this point
// there should be very few or no Jar files that still end up in shards. The dexing
// step below will have to deal with those in addition to merging .dex files together.
- classpath = Iterables
- .transform(classpath, collectDexArchives(ruleContext, common, dexopts, attributes));
+ classpath = Iterables.transform(classpath,
+ collectDexArchives(ruleContext, common, dexopts, semantics, attributes));
shardCommandLine.add("--split_dexed_classes");
}
shardCommandLine.addBeforeEachExecPath("--input_jar", classpath);