The Maven guide for
Configuring for Reproducible Builds
suggests that project.build.outputTimestamp
can be set using ${git.commit.time}
from
git-commit-id-maven-plugin.
This appears to work with maven-jar-plugin
, but maven-site-plugin
returns an error.
To see the error, build this project with:
mvn clean package site
During site generation the following error occurs:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:4.0.0-M9:site (default-site) on project site-plugin-example: Execution defau
lt-site of goal org.apache.maven.plugins:maven-site-plugin:4.0.0-M9:site failed: Invalid project.build.outputTimestamp value '${git.commit.time}': Tex
t '${git.commit.time}' could not be parsed at index 0
As can be seen in the pom.xml
file, I've also defined the implementation.build
parameter using git commit values:
<implementation.build>${git.commit.id.describe}; ${project.build.outputTimestamp}</implementation.build>
Inspecting the MANIFEST.MF
file in the resulting jar file shows that the git commit values have been properly interpolated:
Manifest-Version: 1.0
Created-By: Maven JAR Plugin 3.3.0
Build-Jdk-Spec: 20
Build-Tool: Apache Maven 3.9.3 (21122926829f1ead511c958d89bd2f672198ae9f
)
Build-Jdk: 20.0.1 (Oracle Corporation)
Build-Os: Windows 10 (10.0; amd64)
Specification-Title: Maven Site Plugin Error Example
Specification-Version: 1.0
Specification-Vendor: Bradley Larrick
Implementation-Title: Maven Site Plugin Error Example
Implementation-Version: 1
Implementation-Vendor: Bradley Larrick
Implementation-Build: aec64af-dirty; 2023-07-15T11:14:51-04:00
Implementation-Vendor-Id: org.natuna.examples
X-Compile-Source-JDK: 17
X-Compile-Target-JDK: 17