Skip to content

Commit

Permalink
Make aar_import always process the resources.
Browse files Browse the repository at this point in the history
Previously, the FilesToBuild included the unprocessed resources. This meant that
some bugs did not manifest themselves by building just the aar_import but only
showed up if the aar_import was depended on by an android_library.

--
PiperOrigin-RevId: 141068502
MOS_MIGRATED_REVID=141068502
  • Loading branch information
aj-michael authored and damienmg committed Dec 6, 2016
1 parent 1fccb31 commit c645a45
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public ConfiguredTarget create(RuleContext ruleContext)
FileProvider resourcesProvider = new FileProvider(
new NestedSetBuilder<Artifact>(Order.NAIVE_LINK_ORDER).add(resources).build());

Artifact resourcesZip =
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_RESOURCES_ZIP);

ResourceApk resourceApk = androidManifest.packWithDataAndResources(
ruleContext,
new LocalResourceContainer.Builder(ruleContext)
Expand All @@ -91,11 +94,15 @@ public ConfiguredTarget create(RuleContext ruleContext)
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_R_TXT),
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_SYMBOLS_TXT),
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_PROCESSED_MANIFEST),
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_RESOURCES_ZIP),
resourcesZip,
/* alwaysExportManifest = */ true);

// There isn't really any use case for building an aar_import target on its own, so the files to
// build could be empty. The resources zip and merged jars are added here as a sanity check for
// Bazel developers so that `bazel build java/com/my_aar_import` will fail if the resource
// processing or jar merging steps fail.
NestedSetBuilder<Artifact> filesToBuildBuilder =
NestedSetBuilder.<Artifact>stableOrder().add(resources).add(mergedJar);
NestedSetBuilder.<Artifact>stableOrder().add(resourcesZip).add(mergedJar);

Artifact nativeLibs = createAarArtifact(ruleContext, "native_libs.zip");
ruleContext.registerAction(createAarNativeLibsFilterActions(ruleContext, aar, nativeLibs));
Expand Down

0 comments on commit c645a45

Please sign in to comment.