Example project structure (attached in zip)
- buildnumbertest
-- A
-- B
-- C
-- D
-- E
Here, submodules A,B,C,D,E will try to generate the timestamp concurrently, which will result in different timestamps assigned.
In this scenario the root project does not attempt to generate the timestamp.
Run the follwing command on the root:
mvn install -T4 -X -pl A,B,C,D,E | tee out.txt
then:
cat out.txt | grep "Storing timestamp"
Outputs (which shows that different projects may have different plugins assigned):
[DEBUG] Storing timestamp property: api.test.datetime 09.150811.939
[DEBUG] Storing timestamp property: api.test.datetime 09.150811.955
Note: this is not a deterministic output. Occasionally there is only one timestamp generated.
Investigation:
In the org.codehaus.mojo.build.CreateTimestampMojo class, the block of code, is not synchronized:
if ( timestampString != null )
{
getLog().debug( "Using previously created timestamp." );
return;
}
timestampString = Utils.createTimestamp( timestampFormat, timezone );
getLog().debug( "Storing timestamp property: " + timestampPropertyName + " " + timestampString );
for ( MavenProject project : session.getProjectDependencyGraph().getSort
buildnumbertest.zip
edProjects() )
{
getLog().debug( "Storing timestamp property in project " + project.getId() );
project.getProperties().setProperty( timestampPropertyName, timestampString );
}