diff options
author | 2018-02-16 15:48:49 -0800 | |
---|---|---|
committer | 2018-02-16 15:50:13 -0800 | |
commit | d18d3e2f83f9d582858a3edab7a450c60044028c (patch) | |
tree | 16ff3c0dff1e87a60ddcafaea2917623d48ef096 /src/tools/android/java/com/google/devtools/build/android/Aapt2ResourcePackagingAction.java | |
parent | d7a56179ab35bf21ee6d77d87bb0096bef042175 (diff) |
Automated rollback of commit f672a31b8b19baab95373e4f2f6d110aa8b8f0fb.
*** Reason for rollback ***
Unclassified general breakages in tests. Rolling back for further investigation.
*** Original change description ***
Normalized the serialization proto to save space and allow greater versatility in storage.
RELNOTES: None
PiperOrigin-RevId: 186057879
Diffstat (limited to 'src/tools/android/java/com/google/devtools/build/android/Aapt2ResourcePackagingAction.java')
-rw-r--r-- | src/tools/android/java/com/google/devtools/build/android/Aapt2ResourcePackagingAction.java | 153 |
1 files changed, 77 insertions, 76 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/Aapt2ResourcePackagingAction.java b/src/tools/android/java/com/google/devtools/build/android/Aapt2ResourcePackagingAction.java index 4ef23e76e2..83b628cd9e 100644 --- a/src/tools/android/java/com/google/devtools/build/android/Aapt2ResourcePackagingAction.java +++ b/src/tools/android/java/com/google/devtools/build/android/Aapt2ResourcePackagingAction.java @@ -125,82 +125,83 @@ public class Aapt2ResourcePackagingAction { profiler.recordEndOf("merging"); - profiler.startTask("compile"); - final ResourceCompiler compiler = - ResourceCompiler.create( - executorService, - compiledResources, - aaptConfigOptions.aapt2, - aaptConfigOptions.buildToolsVersion); - - CompiledResources compiled = - options - .primaryData - .processDataBindings( - options.dataBindingInfoOut, options.packageForR, databindingResourcesRoot) - .compile(compiler, compiledResources) - .processManifest( - manifest -> - AndroidManifestProcessor.with(STD_LOGGER) - .processManifest( - options.applicationId, - options.versionCode, - options.versionName, - manifest, - processedManifest)) - .processManifest( - manifest -> - new DensitySpecificManifestProcessor(densities, densityManifest) - .process(manifest)); - profiler.recordEndOf("compile").startTask("link"); - // Write manifestOutput now before the dummy manifest is created. - if (options.manifestOutput != null) { - AndroidResourceOutputs.copyManifestToOutput(compiled, options.manifestOutput); - } - - List<CompiledResources> compiledResourceDeps = - // Last defined dependencies will overwrite previous one, so always place direct - // after transitive. - concat(options.transitiveData.stream(), options.directData.stream()) - .map(DependencyAndroidData::getCompiledSymbols) - .collect(toList()); - - List<Path> assetDirs = - concat(options.transitiveData.stream(), options.directData.stream()) - .flatMap(dep -> dep.assetDirs.stream()) - .collect(toList()); - assetDirs.addAll(options.primaryData.assetDirs); - - final PackagedResources packagedResources = - ResourceLinker.create(aaptConfigOptions.aapt2, linkedOut) - .profileUsing(profiler) - .customPackage(options.packageForR) - .outputAsProto(aaptConfigOptions.resourceTableAsProto) - .dependencies(ImmutableList.of(StaticLibrary.from(aaptConfigOptions.androidJar))) - .include(compiledResourceDeps) - .withAssets(assetDirs) - .buildVersion(aaptConfigOptions.buildToolsVersion) - .conditionalKeepRules(aaptConfigOptions.conditionalKeepRules == TriState.YES) - .filterToDensity(densities) - .includeOnlyConfigs(aaptConfigOptions.resourceConfigs) - .link(compiled) - .copyPackageTo(options.packagePath) - .copyProguardTo(options.proguardOutput) - .copyMainDexProguardTo(options.mainDexProguardOutput) - .createSourceJar(options.srcJarOutput) - .copyRTxtTo(options.rOutput); - profiler.recordEndOf("link"); - if (options.resourcesOutput != null) { - profiler.startTask("package"); - // The compiled resources and the merged resources should be the same. - // TODO(corysmith): Decompile or otherwise provide the exact resources in the apk. - ResourcesZip.fromApk( - mergedAndroidData.getResourceDir(), - packagedResources.getApk(), - packagedResources.getResourceIds()) - .writeTo(options.resourcesOutput, false /* compress */); - profiler.recordEndOf("package"); + + profiler.startTask("compile"); + final ResourceCompiler compiler = + ResourceCompiler.create( + executorService, + compiledResources, + aaptConfigOptions.aapt2, + aaptConfigOptions.buildToolsVersion); + + CompiledResources compiled = + options + .primaryData + .processDataBindings( + options.dataBindingInfoOut, options.packageForR, databindingResourcesRoot) + .compile(compiler, compiledResources) + .processManifest( + manifest -> + AndroidManifestProcessor.with(STD_LOGGER) + .processManifest( + options.applicationId, + options.versionCode, + options.versionName, + manifest, + processedManifest)) + .processManifest( + manifest -> + new DensitySpecificManifestProcessor(densities, densityManifest) + .process(manifest)); + profiler.recordEndOf("compile").startTask("link"); + // Write manifestOutput now before the dummy manifest is created. + if (options.manifestOutput != null) { + AndroidResourceOutputs.copyManifestToOutput(compiled, options.manifestOutput); + } + + List<CompiledResources> compiledResourceDeps = + // Last defined dependencies will overwrite previous one, so always place direct + // after transitive. + concat(options.transitiveData.stream(), options.directData.stream()) + .map(DependencyAndroidData::getCompiledSymbols) + .collect(toList()); + + List<Path> assetDirs = + concat(options.transitiveData.stream(), options.directData.stream()) + .flatMap(dep -> dep.assetDirs.stream()) + .collect(toList()); + assetDirs.addAll(options.primaryData.assetDirs); + + final PackagedResources packagedResources = + ResourceLinker.create(aaptConfigOptions.aapt2, linkedOut) + .profileUsing(profiler) + .customPackage(options.packageForR) + .outputAsProto(aaptConfigOptions.resourceTableAsProto) + .dependencies(ImmutableList.of(StaticLibrary.from(aaptConfigOptions.androidJar))) + .include(compiledResourceDeps) + .withAssets(assetDirs) + .buildVersion(aaptConfigOptions.buildToolsVersion) + .conditionalKeepRules(aaptConfigOptions.conditionalKeepRules == TriState.YES) + .filterToDensity(densities) + .includeOnlyConfigs(aaptConfigOptions.resourceConfigs) + .link(compiled) + .copyPackageTo(options.packagePath) + .copyProguardTo(options.proguardOutput) + .copyMainDexProguardTo(options.mainDexProguardOutput) + .createSourceJar(options.srcJarOutput) + .copyRTxtTo(options.rOutput); + profiler.recordEndOf("link"); + if (options.resourcesOutput != null) { + profiler.startTask("package"); + // The compiled resources and the merged resources should be the same. + // TODO(corysmith): Decompile or otherwise provide the exact resources in the apk. + ResourcesZip.fromApk( + mergedAndroidData.getResourceDir(), + packagedResources.getApk(), + packagedResources.getResourceIds()) + .writeTo(options.resourcesOutput, false /* compress */); + profiler.recordEndOf("package"); + } } } } -} |