This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-artifact-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 0c70871  [MARTIFACT-28] warn if outputTimestamp not defined in reactor 
POM
0c70871 is described below

commit 0c70871d7ad089d7d87141f1cb7825eaa843c8f8
Author: HervĂ© Boutemy <[email protected]>
AuthorDate: Sun Nov 14 19:18:40 2021 +0100

    [MARTIFACT-28] warn if outputTimestamp not defined in reactor POM
---
 src/it/buildinfo-multi/pom.xml                     |  7 ++++++-
 src/it/compare-mono/pom.xml                        |  7 ++++++-
 src/it/compare-mono/verify.groovy                  |  1 -
 .../artifact/buildinfo/AbstractBuildinfoMojo.java  | 23 +++++++++++++++++++---
 4 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/src/it/buildinfo-multi/pom.xml b/src/it/buildinfo-multi/pom.xml
index 30bc7f6..67dc27b 100644
--- a/src/it/buildinfo-multi/pom.xml
+++ b/src/it/buildinfo-multi/pom.xml
@@ -23,6 +23,12 @@
   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>
 
+  <parent>
+    <groupId>org.apache.maven</groupId>
+    <artifactId>maven-parent</artifactId>
+    <version>34</version>
+  </parent>
+
   <groupId>org.apache.maven.plugins.it</groupId>
   <artifactId>multi</artifactId>
   <version>1.0-SNAPSHOT</version>
@@ -32,7 +38,6 @@
 
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-    
<project.build.outputTimestamp>2019-12-03T10:04:00Z</project.build.outputTimestamp>
   </properties>
 
   <prerequisites>
diff --git a/src/it/compare-mono/pom.xml b/src/it/compare-mono/pom.xml
index 5cef77e..0190466 100644
--- a/src/it/compare-mono/pom.xml
+++ b/src/it/compare-mono/pom.xml
@@ -23,6 +23,12 @@
   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>
 
+  <parent>
+    <groupId>org.apache.maven</groupId>
+    <artifactId>maven-parent</artifactId>
+    <version>34</version>
+  </parent>
+
   <groupId>org.apache.maven.plugins.it.compare</groupId>
   <artifactId>mono</artifactId>
   <version>1.0-SNAPSHOT</version>
@@ -31,7 +37,6 @@
 
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-    
<project.build.outputTimestamp>2019-12-03T10:04:00Z</project.build.outputTimestamp>
   </properties>
 
   <prerequisites>
diff --git a/src/it/compare-mono/verify.groovy 
b/src/it/compare-mono/verify.groovy
index 8cbd188..89a233d 100644
--- a/src/it/compare-mono/verify.groovy
+++ b/src/it/compare-mono/verify.groovy
@@ -35,4 +35,3 @@ if( File.separator == '/' ) {
 } else {
   assert compare.contains( '# diffoscope 
target\\reference\\mono-1.0-SNAPSHOT.jar target\\mono-1.0-SNAPSHOT.jar' )
 }
-
diff --git 
a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojo.java
 
b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojo.java
index ebc6e5d..f9be2f1 100644
--- 
a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojo.java
+++ 
b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojo.java
@@ -154,10 +154,27 @@ public abstract class AbstractBuildinfoMojo
             getLog().warn( "Reproducible Build not activated by 
project.build.outputTimestamp property: "
                 + "see 
https://maven.apache.org/guides/mini/guide-reproducible-builds.html"; );
         }
-        else if ( getLog().isDebugEnabled() )
+        else
         {
-            getLog().debug( "project.build.outputTimestamp = \"" + 
outputTimestamp + "\" => "
-                + new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ssXXX" ).format( 
timestamp ) );
+            if ( getLog().isDebugEnabled() )
+            {
+                getLog().debug( "project.build.outputTimestamp = \"" + 
outputTimestamp + "\" => "
+                    + new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ssXXX" 
).format( timestamp ) );
+            }
+
+            // check if timestamp well defined in a project from reactor
+            MavenProject reactorParent = project;
+            while ( reactorProjects.contains( reactorParent.getParent() ) )
+            {
+                reactorParent = reactorParent.getParent();
+            }
+            String prop =
+                reactorParent.getOriginalModel().getProperties().getProperty( 
"project.build.outputTimestamp" );
+            if ( prop == null )
+            {
+                getLog().warn( "project.build.outputTimestamp property should 
not be inherited "
+                    + "but defined in parent POM from reactor " + 
reactorParent.getFile() );
+            }
         }
 
         // generate buildinfo

Reply via email to