Skip to content

Commit

Permalink
gradle: Set lastModified time of jars files to now
Browse files Browse the repository at this point in the history
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 #3118

Signed-off-by: BJ Hargrave <bj@bjhargrave.com>
  • Loading branch information
bjhargrave committed May 31, 2019
1 parent dc328cb commit a7017bd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ public class BndPlugin implements Plugin<Project> {
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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
4 changes: 2 additions & 2 deletions biz.aQute.bndlib/src/aQute/bnd/build/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down

0 comments on commit a7017bd

Please sign in to comment.