From 06f1e5c89b86cf3faf88f3b594d78503084a9e6c Mon Sep 17 00:00:00 2001 From: arunkumar9t2 Date: Tue, 15 Mar 2022 16:13:27 -0700 Subject: [PATCH] Prevent temporary intermediate files from being picked up by Android ResourceCompiler when building with workers. When `--persistent_android_resource_processor` is used alongside databinding, `ResourceCompiler` reads `databinding-processed-resources` folder during resource merging and that folder can contain `*.params` file used for the `PROCESS_DATABINDING` action. 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 remote execution. Fixes https://github.com/bazelbuild/bazel/issues/13649 Closes #14198. PiperOrigin-RevId: 434883392 --- .../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 38831a29e1ff14..5cfcef1d7a3247 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);