[maven-archiver] branch MSHARED-799 updated (199445f -> 7041fca)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[maven-archiver] branch MSHARED-799 updated (199445f -> 7041fca)

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

michaelo pushed a change to branch MSHARED-799
in repository https://gitbox.apache.org/repos/asf/maven-archiver.git.


 discard 199445f  [MSHARED-799] Change "Created-By" manifest entry value to be reproducible
     new 7041fca  [MSHARED-799] Change "Created-By" manifest entry value to be reproducible

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (199445f)
            \
             N -- N -- N   refs/heads/MSHARED-799 (7041fca)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/main/java/org/apache/maven/archiver/MavenArchiver.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Reply | Threaded
Open this post in threaded view
|

[maven-archiver] 01/01: [MSHARED-799] Change "Created-By" manifest entry value to be reproducible

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

michaelo pushed a commit to branch MSHARED-799
in repository https://gitbox.apache.org/repos/asf/maven-archiver.git

commit 7041fcace9210112f6745d880133769f954ef442
Author: Michael Osipov <[hidden email]>
AuthorDate: Fri Feb 1 15:46:45 2019 +0100

    [MSHARED-799] Change "Created-By" manifest entry value to be reproducible
   
    The test method testCreatedByManifestEntryWithoutMavenVersion() has been
    dropped because its function is coverted by two other tests as well.
   
    This closes #4
---
 .../org/apache/maven/archiver/MavenArchiver.java   | 23 ++++++++++++-----
 .../apache/maven/archiver/MavenArchiverTest.java   | 30 +++-------------------
 2 files changed, 20 insertions(+), 33 deletions(-)

diff --git a/src/main/java/org/apache/maven/archiver/MavenArchiver.java b/src/main/java/org/apache/maven/archiver/MavenArchiver.java
index 5213d95..591a464 100644
--- a/src/main/java/org/apache/maven/archiver/MavenArchiver.java
+++ b/src/main/java/org/apache/maven/archiver/MavenArchiver.java
@@ -36,6 +36,7 @@ import org.codehaus.plexus.interpolation.PrefixedPropertiesValueSource;
 import org.codehaus.plexus.interpolation.RecursionInterceptor;
 import org.codehaus.plexus.interpolation.StringSearchInterpolator;
 import org.codehaus.plexus.interpolation.ValueSource;
+import org.apache.maven.shared.utils.PropertyUtils;
 import org.apache.maven.shared.utils.StringUtils;
 
 import javax.lang.model.SourceVersion;
@@ -610,6 +611,8 @@ public class MavenArchiver
         // Create the manifest
         // ----------------------------------------------------------------------
 
+        archiver.setMinimalDefaultManifest( true );
+
         File manifestFile = archiveConfiguration.getManifestFile();
 
         if ( manifestFile != null )
@@ -665,14 +668,11 @@ public class MavenArchiver
     private void addCreatedByEntry( MavenSession session, Manifest m, Map<String, String> entries )
         throws ManifestException
     {
-        String createdBy = "Apache Maven";
-        if ( session != null ) // can be null due to API backwards compatibility
+        String createdBy = "Maven Archiver";
+        String archiverVersion = getArchiverVersion();
+        if ( archiverVersion != null )
         {
-            String mavenVersion = session.getSystemProperties().getProperty( "maven.version" );
-            if ( mavenVersion != null )
-            {
-                createdBy += " " + mavenVersion;
-            }
+            createdBy += " " + archiverVersion;
         }
         addManifestAttribute( m, entries, "Created-By", createdBy );
     }
@@ -703,4 +703,13 @@ public class MavenArchiver
         }
         return null;
     }
+
+    private static String getArchiverVersion()
+    {
+        final Properties properties = PropertyUtils.loadOptionalProperties( MavenArchiver.class.getResourceAsStream(
+            "/META-INF/maven/org.apache.maven/maven-archiver/pom.properties" ) );
+
+        return properties.getProperty( "version" );
+    }
+
 }
diff --git a/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java b/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java
index 2ef472e..77b53df 100644
--- a/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java
+++ b/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java
@@ -489,7 +489,8 @@ public class MavenArchiverTest
         assertTrue( jarFile.exists() );
         Attributes manifest = getJarFileManifest( jarFile ).getMainAttributes();
 
-        assertEquals( "Apache Maven", manifest.get( new Attributes.Name( "Created-By" ) ) ); // no version number
+        // no version number
+        assertEquals( "Maven Archiver", manifest.get( new Attributes.Name( "Created-By" ) ) );
 
         assertEquals( "archiver test", manifest.get( Attributes.Name.SPECIFICATION_TITLE ) );
         assertEquals( "0.1", manifest.get( Attributes.Name.SPECIFICATION_VERSION ) );
@@ -540,7 +541,8 @@ public class MavenArchiverTest
         final Manifest jarFileManifest = getJarFileManifest( jarFile );
         Attributes manifest = jarFileManifest.getMainAttributes();
 
-        assertEquals( "Apache Maven 3.0.4", manifest.get( new Attributes.Name( "Created-By" ) ) );
+        // no version number
+        assertEquals( "Maven Archiver", manifest.get( new Attributes.Name( "Created-By" ) ) );
 
         assertEquals( session.getSystemProperties().get( "maven.build.version" ),
             manifest.get( new Attributes.Name( "Build-Tool" ) ) );
@@ -602,30 +604,6 @@ public class MavenArchiverTest
         }
     }
 
-    @Test
-    public void testCreatedByManifestEntryWithoutMavenVersion()
-        throws Exception
-    {
-        File jarFile = new File( "target/test/dummy.jar" );
-        JarArchiver jarArchiver = getCleanJarArchiver( jarFile );
-
-        MavenArchiver archiver = getMavenArchiver( jarArchiver );
-
-        MavenSession session = getDummySessionWithoutMavenVersion();
-        MavenProject project = getDummyProject();
-
-        MavenArchiveConfiguration config = new MavenArchiveConfiguration();
-        config.setForced( true );
-
-        archiver.createArchive( session, project, config );
-        assertTrue( jarFile.exists() );
-
-        final Manifest manifest = getJarFileManifest( jarFile );
-        Map<Object, Object> entries = manifest.getMainAttributes();
-
-        assertEquals( "Apache Maven", entries.get( new Attributes.Name( "Created-By" ) ) );
-    }
-
     /*
      * Test to make sure that manifest sections are present in the manifest prior to the archive has been created.
      */