Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 214773061
  • Loading branch information
corbinrsmith-work authored and Copybara-Service committed Sep 27, 2018
1 parent d93ebe1 commit 4fea242
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ public static ProcessedAndroidData processBinaryDataFrom(

AndroidResourcesProcessorBuilder builder =
builderForNonIncrementalTopLevelTarget(dataContext, manifest, manifestValues, aaptVersion)
.setUseCompiledResourcesForMerge(
aaptVersion == AndroidAaptVersion.AAPT2
&& dataContext.getAndroidConfig().skipParsingAction())
.setUseCompiledResourcesForMerge(aaptVersion == AndroidAaptVersion.AAPT2)
.setManifestOut(
dataContext.createOutputArtifact(AndroidRuleClasses.ANDROID_PROCESSED_MANIFEST))
.setMergedResourcesOut(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4327,7 +4327,7 @@ public void testSkipParsingActionFlagGetsPropagated() throws Exception {
ConfiguredTarget b = getDirectPrerequisite(a, "//java/b:b");

List<String> resourceProcessingArgs =
getGeneratingSpawnActionArgs(getValidatedResources(a).getRTxt());
getGeneratingSpawnActionArgs(getValidatedResources(a).getApk());

assertThat(resourceProcessingArgs).contains("AAPT2_PACKAGE");
String directData =
Expand All @@ -4343,6 +4343,50 @@ public void testSkipParsingActionFlagGetsPropagated() throws Exception {
assertThat(resourceMergingArgs).contains("MERGE_COMPILED");
}

@Test
public void alwaysSkipParsingActionWithAapt2() throws Exception {
mockAndroidSdkWithAapt2();
scratch.file(
"java/b/BUILD",
"android_library(",
" name = 'b',",
" srcs = ['B.java'],",
" manifest = 'AndroidManifest.xml',",
" resource_files = [ 'res/values/values.xml' ], ",
")");

scratch.file(
"java/a/BUILD",
"android_binary(",
" name = 'a',",
" srcs = ['A.java'],",
" manifest = 'AndroidManifest.xml',",
" deps = [ '//java/b:b' ],",
" resource_files = [ 'res/values/values.xml' ], ",
" aapt_version = 'aapt2'",
")");

useConfiguration("--android_sdk=//sdk:sdk");
ConfiguredTarget a = getConfiguredTarget("//java/a:a");
ConfiguredTarget b = getDirectPrerequisite(a, "//java/b:b");

List<String> resourceProcessingArgs =
getGeneratingSpawnActionArgs(getValidatedResources(a).getApk());

assertThat(resourceProcessingArgs).contains("AAPT2_PACKAGE");
String directData =
resourceProcessingArgs.get(resourceProcessingArgs.indexOf("--directData") + 1);
assertThat(directData).contains("symbols.zip");
assertThat(directData).doesNotContain("merged.bin");
assertThat(resourceProcessingArgs).contains("--useCompiledResourcesForMerge");

// Libraries will still need to merge the xml until skip parsing is on by default.
List<String> resourceMergingArgs =
getGeneratingSpawnActionArgs(getValidatedResources(b).getJavaClassJar());

assertThat(resourceMergingArgs).contains("MERGE");
}

@Test
public void testAapt1BuildsWithAapt2Sdk() throws Exception {
mockAndroidSdkWithAapt2();
Expand Down

0 comments on commit 4fea242

Please sign in to comment.