[maven-archiver] branch master updated: MSHARED-835 add an API to remove Build-Jdk-Spec default manifest entry

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[maven-archiver] branch master updated: MSHARED-835 add an API to remove Build-Jdk-Spec default manifest entry

hboutemy
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-archiver.git


The following commit(s) were added to refs/heads/master by this push:
     new 60ce414  MSHARED-835 add an API to remove Build-Jdk-Spec default manifest entry
60ce414 is described below

commit 60ce41451ed58bc72edba92dfefdf811ad901d03
Author: Hervé Boutemy <[hidden email]>
AuthorDate: Sun Sep 8 17:10:30 2019 +0200

    MSHARED-835 add an API to remove Build-Jdk-Spec default manifest entry
---
 .../org/apache/maven/archiver/MavenArchiver.java     | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/maven/archiver/MavenArchiver.java b/src/main/java/org/apache/maven/archiver/MavenArchiver.java
index c2d01be..521f5c2 100644
--- a/src/main/java/org/apache/maven/archiver/MavenArchiver.java
+++ b/src/main/java/org/apache/maven/archiver/MavenArchiver.java
@@ -107,6 +107,7 @@ public class MavenArchiver
 
     private String createdBy;
 
+    private boolean buildJdkSpecDefaultEntry = true;
     /**
      * @param session The Maven Session.
      * @param project The Maven Project.
@@ -680,7 +681,10 @@ public class MavenArchiver
              createdBy = createdBy( CREATED_BY, "org.apache.maven", "maven-archiver" );
          }
          addManifestAttribute( m, entries, "Created-By", createdBy );
-         addManifestAttribute( m, entries, "Build-Jdk-Spec", System.getProperty( "java.specification.version" ) );
+         if ( buildJdkSpecDefaultEntry )
+         {
+             addManifestAttribute( m, entries, "Build-Jdk-Spec", System.getProperty( "java.specification.version" ) );
+         }
     }
 
     private void handleBuildEnvironmentEntries( MavenSession session, Manifest m, Map<String, String> entries )
@@ -724,7 +728,7 @@ public class MavenArchiver
      * @param description description of the plugin, like "Maven Source Plugin"
      * @param groupId groupId where to get version in pom.properties
      * @param artifactId artifactId where to get version in pom.properties
-     * @since 3.5.0
+     * @since 3.4.1
      */
     public void setCreatedBy( String description, String groupId, String artifactId )
     {
@@ -742,4 +746,16 @@ public class MavenArchiver
         return createdBy;
     }
 
+    /**
+     * Add "Build-Jdk-Spec" entry as part of default manifest entries (true by default).
+     * For plugins whose output is not impacted by JDK release (like maven-source-plugin), adding
+     * Jdk spec adds unnecessary requirement on JDK version used at build to get reproducible result.
+     *
+     * @since 3.4.1
+     */
+    public void setBuildJdkSpecDefaultEntry( boolean buildJdkSpecDefaultEntry )
+    {
+        this.buildJdkSpecDefaultEntry = buildJdkSpecDefaultEntry;
+    }
+
 }