From f461c10b9fa17d57f79721c50b98d9a2bdc1017f Mon Sep 17 00:00:00 2001 From: Kyle Moore Date: Mon, 22 Mar 2021 22:09:50 -0700 Subject: [PATCH] Make pegasus artifacts reproducible --- .../java/com/linkedin/pegasus/gradle/PegasusPlugin.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gradle-plugins/src/main/java/com/linkedin/pegasus/gradle/PegasusPlugin.java b/gradle-plugins/src/main/java/com/linkedin/pegasus/gradle/PegasusPlugin.java index 898ef34393..f2187bcefb 100644 --- a/gradle-plugins/src/main/java/com/linkedin/pegasus/gradle/PegasusPlugin.java +++ b/gradle-plugins/src/main/java/com/linkedin/pegasus/gradle/PegasusPlugin.java @@ -71,6 +71,7 @@ import org.gradle.api.tasks.SourceSetContainer; import org.gradle.api.tasks.Sync; import org.gradle.api.tasks.TaskProvider; +import org.gradle.api.tasks.bundling.AbstractArchiveTask; import org.gradle.api.tasks.bundling.Jar; import org.gradle.api.tasks.compile.JavaCompile; import org.gradle.api.tasks.javadoc.Javadoc; @@ -1831,6 +1832,13 @@ protected GenerateDataTemplateTask configureDataTemplateGeneration(Project proje // FIXME change to #getArchiveFile(); breaks backwards-compatibility before 5.1 project.getDependencies().add(compileConfigName, project.files(dataTemplateJarTask.getArchivePath())); + // make pegasus artifacts reproducible + // see https://docs.gradle.org/6.8.3/userguide/working_with_files.html#sec:reproducible_archives + project.getTasks().withType(AbstractArchiveTask.class).configureEach(task -> { + task.setPreserveFileTimestamps(false); + task.setReproducibleFileOrder(true); + }); + project.getPlugins().withType(IvyPublishPlugin.class, ivyPublish -> { if (!isAtLeastGradle61()) { throw new GradleException("Using the ivy-publish plugin with the pegasus plugin requires Gradle 6.1 or higher " +