From 8736e0958af4705d0e45dac8c13cd7b074e4842b Mon Sep 17 00:00:00 2001 From: arunkumar9t2 Date: Sat, 30 Oct 2021 04:23:00 +0800 Subject: [PATCH] Prevent temporary intermediate files from being picked up by Android ResourceCompiler when running with workers. When `--persistent_android_resource_processor` is used alongside databinding, ResourceCompiler reads `databinding-processed-resources` during resource merging and that folder can contain ``*.params` file for each processed layout resource. This causes resource compiler's file name validation to fail. This CL simply ignores staging the intermediate files for resource compilation. Additionally this CL also excludes *.tmp files which were observed when using dynamic execution. Fixes https://github.com/bazelbuild/bazel/issues/13649 --- .../devtools/build/android/aapt2/ResourceCompiler.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 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 1e1ccf91279e24..69dfa1c2fe26b6 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 @@ -357,8 +357,12 @@ public CompilingVisitor( @Override 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(".")) { + // Ignore directories and "hidden" files that start with ., ends with .tmp or .params files. + final String fileName = file.getFileName().toString(); + if (!Files.isDirectory(file) + && !fileName.startsWith(".") + && !fileName.endsWith(".tmp") + && !fileName.endsWith(".params")) { pathToProcessed.add(file); } return super.visitFile(file, attrs);