From a7017bd305fa6364fa58d70adf0cc7b737c5038d Mon Sep 17 00:00:00 2001 From: BJ Hargrave Date: Fri, 31 May 2019 15:04:30 -0400 Subject: [PATCH] gradle: Set lastModified time of jars files to now When the Bnd gradle plugin writes a jar file, we need to set the time of the file to the time it is written instead of the default which is the time of the most recent resource in the jar file. Fixes https://github.com/bndtools/bnd/issues/3118 Signed-off-by: BJ Hargrave --- biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndPlugin.groovy | 4 ++++ .../src/aQute/bnd/gradle/BundleTaskConvention.groovy | 2 ++ biz.aQute.bndlib/src/aQute/bnd/build/Project.java | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndPlugin.groovy b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndPlugin.groovy index e20f3d4a21..2cad496768 100644 --- a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndPlugin.groovy +++ b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndPlugin.groovy @@ -284,6 +284,10 @@ public class BndPlugin implements Plugin { File[] built try { built = bndProject.build() + long now = System.currentTimeMillis() + built?.each { + it.setLastModified(now) + } } catch (Exception e) { throw new GradleException("Project ${bndProject.getName()} failed to build", e) } diff --git a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BundleTaskConvention.groovy b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BundleTaskConvention.groovy index 9e129ef5bc..294a1fdd43 100644 --- a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BundleTaskConvention.groovy +++ b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BundleTaskConvention.groovy @@ -295,6 +295,8 @@ class BundleTaskConvention { // Write out the bundle builtJar.write(archivePath) + long now = System.currentTimeMillis() + archivePath.setLastModified(now) logReport(builder, logger) if (!builder.isOk()) { diff --git a/biz.aQute.bndlib/src/aQute/bnd/build/Project.java b/biz.aQute.bndlib/src/aQute/bnd/build/Project.java index 2a7a018709..7921a079ef 100644 --- a/biz.aQute.bndlib/src/aQute/bnd/build/Project.java +++ b/biz.aQute.bndlib/src/aQute/bnd/build/Project.java @@ -1891,8 +1891,8 @@ public File[] buildLocal(boolean underTest) throws Exception { return null; } builtFiles.add(file); - if (lastModified < file.lastModified()) { - lastModified = file.lastModified(); + if (lastModified < jar.lastModified()) { + lastModified = jar.lastModified(); } }