Skip to content

Commit

Permalink
Merge pull request #104 from basil/reproducible
Browse files Browse the repository at this point in the history
Support for Maven reproducible builds
  • Loading branch information
jglick authored Apr 12, 2024
2 parents e33d6fc + 0930bde commit 941aabd
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void afterSessionStart(MavenSession session) throws MavenExecutionExcepti
long start = System.nanoTime();
File dir = session.getRequest().getMultiModuleProjectDirectory();
log.debug("running in " + dir);
String fullHash, hash;
String fullHash, hash, timestamp;
int count;
try (Git git = Git.open(dir)) {
Status status = git.status().call();
Expand All @@ -100,6 +100,7 @@ public void afterSessionStart(MavenSession session) throws MavenExecutionExcepti
hash = head.abbreviate(ABBREV_LENGTH).name();
try (RevWalk walk = new RevWalk(repo)) {
RevCommit headC = walk.parseCommit(head);
timestamp = DateTimeFormatter.ISO_INSTANT.format(Instant.ofEpochSecond(headC.getCommitTime()));
count = revCount(walk, headC);
{ // Look for repository commits reachable from HEAD that would clash.
Map<String,List<RevCommit>> encountered = new HashMap<>();
Expand Down Expand Up @@ -133,9 +134,10 @@ public void afterSessionStart(MavenSession session) throws MavenExecutionExcepti
}
log.debug("Spent " + (System.nanoTime() - start) / 1000 / 1000 + "ms on calculations");
String value = String.format(props.getProperty("changelist.format", "-rc%d.%s"), count, sanitize(hash));
log.info("Setting: -Dchangelist=" + value + " -DscmTag=" + fullHash);
log.info("Setting: -Dchangelist=" + value + " -DscmTag=" + fullHash + " -Dproject.build.outputTimestamp=" + timestamp);
props.setProperty("changelist", value);
props.setProperty("scmTag", fullHash);
props.setProperty("project.build.outputTimestamp", timestamp);
} else {
log.info("Declining to override the `changelist` or `scmTag` properties");
}
Expand Down

0 comments on commit 941aabd

Please sign in to comment.