You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2019/02/01 14:47:50 UTC
[maven-archiver] branch MSHARED-799 created (now 199445f)
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.
at 199445f [MSHARED-799] Change "Created-By" manifest entry value to be reproducible
This branch includes the following new commits:
new 199445f [MSHARED-799] Change "Created-By" manifest entry value to be reproducible
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.
[maven-archiver] 01/01: [MSHARED-799] Change "Created-By" manifest
entry value to be reproducible
Posted by mi...@apache.org.
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 199445f810b06810cdca08c41b536c280410b870
Author: Michael Osipov <mi...@apache.org>
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.
---
.../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..4bcb2f5 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 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.
*/