From 665de2fe5fa45cee8215fc6c6dab8ec5250b8f57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Wed, 22 Jan 2025 16:47:10 +0100 Subject: [PATCH] Use sync instead of delete-then-copy --- .../com/google/protobuf/gradle/CopyActionFacade.java | 11 +++++++++++ .../com/google/protobuf/gradle/ProtobufExtract.groovy | 5 +---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/groovy/com/google/protobuf/gradle/CopyActionFacade.java b/src/main/groovy/com/google/protobuf/gradle/CopyActionFacade.java index 64e08389..e4363641 100644 --- a/src/main/groovy/com/google/protobuf/gradle/CopyActionFacade.java +++ b/src/main/groovy/com/google/protobuf/gradle/CopyActionFacade.java @@ -50,6 +50,7 @@ interface CopyActionFacade { WorkResult copy(Action var1); WorkResult delete(Action action); + WorkResult sync(Action var1); @CompileStatic final class Loader { @@ -79,6 +80,11 @@ public WorkResult copy(Action action) { public WorkResult delete(Action action) { return project.delete(action); } + + @Override + public WorkResult sync(Action action) { + return project.sync(action); + } } @CompileStatic @@ -95,5 +101,10 @@ public WorkResult copy(Action action) { public WorkResult delete(Action action) { return getFileSystemOperations().delete(action); } + + @Override + public WorkResult sync(Action action) { + return getFileSystemOperations().sync(action); + } } } diff --git a/src/main/groovy/com/google/protobuf/gradle/ProtobufExtract.groovy b/src/main/groovy/com/google/protobuf/gradle/ProtobufExtract.groovy index 514900e7..22d92356 100644 --- a/src/main/groovy/com/google/protobuf/gradle/ProtobufExtract.groovy +++ b/src/main/groovy/com/google/protobuf/gradle/ProtobufExtract.groovy @@ -84,10 +84,7 @@ abstract class ProtobufExtract extends DefaultTask { @TaskAction public void extract() { - copyActionFacade.delete { spec -> - spec.delete(destDir) - } - copyActionFacade.copy { spec -> + copyActionFacade.sync { spec -> spec.includeEmptyDirs = false spec.from(inputProtoFiles) spec.into(destDir)