Skip to content

Commit

Permalink
#568 introduce updateBuildOutputTimestamp property to make it configu…
Browse files Browse the repository at this point in the history
…rable whether project.build.outputTimestamp is updated or not
  • Loading branch information
stefanseifert committed Mar 11, 2022
1 parent 8cfe5d0 commit ba4e673
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:set -DnewVersion=2.0 -DupdateBuildOutputTimestamp=false
14 changes: 14 additions & 0 deletions src/it/it-set-020-outputTimestamp-disabled/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>localhost</groupId>
<artifactId>it-set-020-outputTimestamp-disabled</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>set</name>

<properties>
<project.build.outputTimestamp>10</project.build.outputTimestamp>
</properties>
</project>
4 changes: 4 additions & 0 deletions src/it/it-set-020-outputTimestamp-disabled/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pom = new File( basedir, "pom.xml" ).text;

// expect outputTimestamp to be untouched
assert pom =~ /<project.build.outputTimestamp>10<.project.build.outputTimestamp>/
14 changes: 12 additions & 2 deletions src/main/java/org/codehaus/mojo/versions/SetMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,14 @@ public class SetMojo
@Parameter( property = "processFromLocalAggregationRoot", defaultValue = "true" )
private boolean processFromLocalAggregationRoot;

/**
* Whether to update the <code>project.build.outputTimestamp<code> property in the POM when setting version.
*
* @since 2.10
*/
@Parameter( property = "updateBuildOutputTimestamp", defaultValue = "true" )
private boolean updateBuildOutputTimestamp;

/**
* The changes to module coordinates. Guarded by this.
*/
Expand Down Expand Up @@ -506,8 +514,10 @@ protected synchronized void update( ModifiedPomXMLEventReader pom )
{
changer.apply( versionChange );

// also update project.build.outputTimestamp
updateBuildOutputTimestamp( pom, model );
if (updateBuildOutputTimestamp) {
// also update project.build.outputTimestamp
updateBuildOutputTimestamp( pom, model );
}
}
}
catch ( IOException e )
Expand Down

0 comments on commit ba4e673

Please sign in to comment.