aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/android/java/com/google/devtools/build/android/aapt2/ResourceCompiler.java
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2018-01-10 13:10:47 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-01-10 13:12:55 -0800
commitee28bc3a15a7eeeccf21b39b3d307b64ae8acee4 (patch)
tree744dd777fafa131fe1d644da0b5d4a4637fd9c03 /src/tools/android/java/com/google/devtools/build/android/aapt2/ResourceCompiler.java
parentea41dc4f5179533c3c54a786848157cc17dccac2 (diff)
Fix parsing for some aapt2-generated resources.
RELNOTES: none PiperOrigin-RevId: 181506851
Diffstat (limited to 'src/tools/android/java/com/google/devtools/build/android/aapt2/ResourceCompiler.java')
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/aapt2/ResourceCompiler.java31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/aapt2/ResourceCompiler.java b/src/tools/android/java/com/google/devtools/build/android/aapt2/ResourceCompiler.java
index 50c5ff5b13..75ac26a993 100644
--- a/src/tools/android/java/com/google/devtools/build/android/aapt2/ResourceCompiler.java
+++ b/src/tools/android/java/com/google/devtools/build/android/aapt2/ResourceCompiler.java
@@ -215,17 +215,34 @@ public class ResourceCompiler {
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// Ignore directories and "hidden" files that start with .
if (!Files.isDirectory(file) && !file.getFileName().toString().startsWith(".")) {
+ // Creates a relative output path based on the input path under the
+ // compiledResources path.
+ Path outputDirectory = Files.createDirectories(
+ compiledResources.resolve(
+ (file.isAbsolute() ? file.getRoot().relativize(file) : file)
+ .getParent()
+ .getParent()));
+
+ String resFolder = file.getParent().getFileName().toString().toLowerCase();
+
+ // Aapt cannot interpret these regions so we rename them to get them to compile
+ String renamedResFolder = resFolder
+ .replaceFirst("sr[_\\-]r?latn", "b+sr+Latn")
+ .replaceFirst("es[_\\-]419", "b+es+419");
+
+ if (!renamedResFolder.equals(resFolder)) {
+ file = Files.copy(
+ file,
+ Files.createDirectory(
+ outputDirectory.resolve(renamedResFolder))
+ .resolve(file.getFileName()));
+ }
+
tasks.add(
executorService.submit(
new CompileTask(
file,
- // Creates a relative output path based on the input path under the
- // compiledResources path.
- Files.createDirectories(
- compiledResources.resolve(
- (file.isAbsolute() ? file.getRoot().relativize(file) : file)
- .getParent()
- .getParent())),
+ outputDirectory,
aapt2,
buildToolsVersion)));
}