Skip to content

Commit 1369698

Browse files
authored
Merge pull request #310 from elektro-wolle/optional-outputTimestamp
Makes update of outputTimestamp property optional
2 parents daa4e50 + 49e0ca3 commit 1369698

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ To configure your Maven build to support reproducible builds follow [official gu
109109

110110
If your project has `project.build.outputTimestamp` property this plugin will update its value whenever the versions are updated.
111111

112+
This can be disabled by setting the configuration parameter `updateOutputTimestamp` to `false`.
113+
112114

113115
# Plugin Common Parameters
114116

src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo {
180180
@Parameter(defaultValue = "${session}", readonly = true)
181181
protected MavenSession mavenSession;
182182

183+
/**
184+
* Whether to update the <code>project.build.outputTimestamp</code> property automatically or not.
185+
*
186+
* @since 1.16.1
187+
*/
188+
@Parameter(property = "updateOutputTimestamp", defaultValue = "true")
189+
private boolean updateOutputTimestamp = true;
190+
183191
@Component
184192
protected ProjectBuilder projectBuilder;
185193

@@ -1056,22 +1064,24 @@ protected void mvnSetVersions(final String version) throws MojoFailureException,
10561064
if (runCommand) {
10571065
executeMvnCommand(args.toArray(new String[0]));
10581066

1059-
String timestamp = getCurrentProjectOutputTimestamp();
1060-
if (timestamp != null && timestamp.length() > 1) {
1061-
if (StringUtils.isNumeric(timestamp)) {
1062-
// int representing seconds since the epoch
1063-
timestamp = String.valueOf(System.currentTimeMillis() / 1000l);
1064-
} else {
1065-
// ISO-8601
1066-
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
1067-
df.setTimeZone(TimeZone.getTimeZone("UTC"));
1068-
timestamp = df.format(new Date());
1067+
if (updateOutputTimestamp) {
1068+
String timestamp = getCurrentProjectOutputTimestamp();
1069+
if (timestamp != null && timestamp.length() > 1) {
1070+
if (StringUtils.isNumeric(timestamp)) {
1071+
// int representing seconds since the epoch
1072+
timestamp = String.valueOf(System.currentTimeMillis() / 1000l);
1073+
} else {
1074+
// ISO-8601
1075+
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
1076+
df.setTimeZone(TimeZone.getTimeZone("UTC"));
1077+
timestamp = df.format(new Date());
1078+
}
1079+
1080+
getLog().info("Updating property '" + REPRODUCIBLE_BUILDS_PROPERTY + "' to '" + timestamp + "'.");
1081+
1082+
executeMvnCommand(VERSIONS_MAVEN_PLUGIN_SET_PROPERTY_GOAL, "-DgenerateBackupPoms=false",
1083+
"-Dproperty=" + REPRODUCIBLE_BUILDS_PROPERTY, "-DnewVersion=" + timestamp);
10691084
}
1070-
1071-
getLog().info("Updating property '" + REPRODUCIBLE_BUILDS_PROPERTY + "' to '" + timestamp + "'.");
1072-
1073-
executeMvnCommand(VERSIONS_MAVEN_PLUGIN_SET_PROPERTY_GOAL, "-DgenerateBackupPoms=false",
1074-
"-Dproperty=" + REPRODUCIBLE_BUILDS_PROPERTY, "-DnewVersion=" + timestamp);
10751085
}
10761086
}
10771087
}

0 commit comments

Comments
 (0)