From 6887bad6695b19efbb7e349115258efb44c23312 Mon Sep 17 00:00:00 2001 From: John Plaisted Date: Fri, 4 Jun 2021 14:47:24 -0700 Subject: [PATCH] fix: fix gradle caching issue (#100) * fix: fix gradle caching issue * remove unused import --- .../metadata/gradle/tasks/GenerateMetadataEventsTask.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gradle-plugins/metadata-events-generator-plugin/src/main/java/com/linkedin/metadata/gradle/tasks/GenerateMetadataEventsTask.java b/gradle-plugins/metadata-events-generator-plugin/src/main/java/com/linkedin/metadata/gradle/tasks/GenerateMetadataEventsTask.java index 615d779c2..82e1cae95 100644 --- a/gradle-plugins/metadata-events-generator-plugin/src/main/java/com/linkedin/metadata/gradle/tasks/GenerateMetadataEventsTask.java +++ b/gradle-plugins/metadata-events-generator-plugin/src/main/java/com/linkedin/metadata/gradle/tasks/GenerateMetadataEventsTask.java @@ -6,6 +6,7 @@ import java.io.IOException; import java.util.stream.Collectors; import javax.annotation.Nonnull; +import org.apache.commons.io.FileUtils; import org.gradle.api.DefaultTask; import org.gradle.api.file.ConfigurableFileCollection; import org.gradle.api.provider.Property; @@ -59,6 +60,12 @@ public Property getEntitiesAnnotationAllowList() @TaskAction public void generateEvents() throws IOException { final SchemaGenerator schemaGenerator = new SchemaGenerator(); + + // For caching to work across git branches, this entire directory needs to be deleted. The entire directory is + // cached; so if anything is left in here from other branch builds it will be incorrectly cached. Delete it to + // ensure that it is in 100% valid state after this task (and when cached). + FileUtils.deleteDirectory(getOutputDirectory().getSingleFile()); + final String outputDir = getOutputDirectory().getSingleFile().toPath().resolve("com").resolve("linkedin").resolve("mxe").toString(); schemaGenerator.generate(_resolverPaths.getFiles().stream().map(File::toString).collect(Collectors.toList()),