diff options
author | Googler <noreply@google.com> | 2016-11-21 23:51:53 +0000 |
---|---|---|
committer | Dmitry Lomov <dslomov@google.com> | 2016-11-22 14:14:59 +0000 |
commit | 7d32e255fb47bc2bb4e9ec1644ab272005758336 (patch) | |
tree | f3b78371df1db0d32107c701ebd82a4ad985aa10 /src/main/java/com/google/devtools/build/lib/rules/android | |
parent | baeff7fe2b192afb13c7a8b7bb40ee406c946ba7 (diff) |
try using default bootclasspath for android desugaring if JavaCompilationInfoProvider is missing
--
MOS_MIGRATED_REVID=139842250
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/android')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/android/DexArchiveAspect.java | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/DexArchiveAspect.java b/src/main/java/com/google/devtools/build/lib/rules/android/DexArchiveAspect.java index 59b1df5eef..de29a01d2d 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/DexArchiveAspect.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/DexArchiveAspect.java @@ -116,6 +116,11 @@ public final class DexArchiveAspect extends NativeAspectClass implements Configu // Parse labels since we don't have RuleDefinitionEnvironment.getLabel like in a rule .add(attr(ASPECT_DESUGAR_PREREQ, LABEL).cfg(HOST).exec() .value(Label.parseAbsoluteUnchecked(toolsRepository + "//tools/android:desugar_java8"))) + // Access to --android_sdk so we can stub in a bootclasspath for desugaring if missing + .add(attr(":dex_archive_android_sdk", LABEL) + .allowedRuleClasses("android_sdk", "filegroup") + .value(new AndroidRuleClasses.AndroidSdkLabel( + Label.parseAbsoluteUnchecked(toolsRepository + AndroidRuleClasses.DEFAULT_SDK)))) .requiresConfigurationFragments(AndroidConfiguration.class); if (TriState.valueOf(params.getOnlyValueOfAttribute("incremental_dexing")) != TriState.NO) { // Marginally improves "query2" precision for targets that disable incremental dexing @@ -199,7 +204,7 @@ public final class DexArchiveAspect extends NativeAspectClass implements Configu .getRecursiveJavaCompilationArgs() .getCompileTimeJars(); // For android_* targets we need to honor their bootclasspath (nicer in general to do so) - ImmutableList<Artifact> bootclasspath = getBootclasspath(base); + ImmutableList<Artifact> bootclasspath = getBootclasspath(base, ruleContext); for (Artifact jar : jarProvider.getRuntimeJars()) { Artifact desugared = createDesugarAction(ruleContext, jar, bootclasspath, compileTimeClasspath); @@ -222,11 +227,16 @@ public final class DexArchiveAspect extends NativeAspectClass implements Configu return result.build(); } - private static ImmutableList<Artifact> getBootclasspath(ConfiguredTarget base) { + private static ImmutableList<Artifact> getBootclasspath(ConfiguredTarget base, + RuleContext ruleContext) { JavaCompilationInfoProvider compilationInfo = base.getProvider(JavaCompilationInfoProvider.class); - if (compilationInfo == null) { - return ImmutableList.of(); + if (compilationInfo == null || compilationInfo.getBootClasspath().isEmpty()) { + return ImmutableList.of( + ruleContext + .getPrerequisite(":dex_archive_android_sdk", Mode.TARGET) + .getProvider(AndroidSdkProvider.class) + .getAndroidJar()); } return compilationInfo.getBootClasspath(); } |