Skip to content

Commit

Permalink
[MASSEMBLY-986] Minimal default Manifest configuration of jar archive…
Browse files Browse the repository at this point in the history
…r should be respected (#134)
  • Loading branch information
slawekjaranowski authored May 3, 2023
1 parent 17e7eb5 commit 2d61b0f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/it/projects/reproducible/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</descriptors>
<archive>
<manifest>
<!-- remove default entries since it contains "Created-By: Maven Source Plugin <current plugin version>"
<!-- remove default entries since it contains "Created-By: Maven Assembly Plugin <current plugin version>"
which varies over time in this IT -->
<addDefaultEntries>false</addDefaultEntries>
</manifest>
Expand Down
9 changes: 8 additions & 1 deletion src/it/projects/reproducible/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@
* under the License.
*/

//import java.util.zip.*
import java.util.jar.*;
import org.apache.commons.compress.archivers.zip.*

File deployDir = new File( basedir, 'target/repo/org/apache/maven/its/reproducible/1.0' )

assert deployDir.exists()

// Minimal Manifest was created
JarFile jarFile = new JarFile( new File( deployDir, "reproducible-1.0-src.jar" ) )
Manifest mf = jarFile.getManifest()
Attributes attrs = mf.getMainAttributes()
assert attrs.size() == 1
assert attrs.containsKey(Attributes.Name.MANIFEST_VERSION)

ZipFile zip = new ZipFile( new File( deployDir, "reproducible-1.0-src.zip" ) )
StringBuilder sb = new StringBuilder()
StringBuilder sb2 = new StringBuilder()
Expand Down
2 changes: 1 addition & 1 deletion src/it/projects/reproducible/zip-content-755.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ executable: 100755

resulting sha1:
97d0ea3b4a87cd3ea78edd1c3c25914d69ea97f3 reproducible-1.0-src.zip.sha1
a0c4cf1ed244e60221e12367f50ff676066b8e65 reproducible-1.0-src.jar.sha1
d3aec46dedbfc5dcb31f7055f130860aeb8fcf66 reproducible-1.0-src.jar.sha1
bf93dd529253157352b87097d9d23eba8c9ca61a reproducible-1.0-src.tar.sha1
2 changes: 1 addition & 1 deletion src/it/projects/reproducible/zip-content-775.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ executable: 100775

resulting sha1:
50116502c6107740c2a35ef296b5abda08c5dec7 reproducible-1.0-src.zip.sha1
cc7e3a984179f63d6b37bc86c61e9cc461c62288 reproducible-1.0-src.jar.sha1
3bb81a423ca18a01dd76e0f872c66a1a7528f064 reproducible-1.0-src.jar.sha1
3efc10ec9c3099ba061e58d5b2a935ba643da237 reproducible-1.0-src.tar.sha1
2 changes: 1 addition & 1 deletion src/it/projects/reproducible/zip-content-win.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ executable: 100644

resulting sha1:
cb1dc226d702733bfa405b7090b74ab7e77bf39e reproducible-1.0-src.zip.sha1
3b31d88a36985f526fb3fe6ba5987387e4887f23 reproducible-1.0-src.jar.sha1
a916d0299f54a790ede766709ce54daebef5e818 reproducible-1.0-src.jar.sha1
b85f960069d6a444f928a87761b63fde60ea687d reproducible-1.0-src.tar.sha1
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,7 @@ protected Archiver createArchiver(
final List<FileSelector> extraSelectors = new ArrayList<>();
final List<ArchiveFinalizer> extraFinalizers = new ArrayList<>();
if (archiver instanceof JarArchiver) {
if (mergeManifestMode != null) {
((JarArchiver) archiver)
.setFilesetmanifest(JarArchiver.FilesetManifestConfig.valueOf(mergeManifestMode));
}
configureJarArchiver((JarArchiver) archiver, mergeManifestMode);

extraSelectors.add(new JarSecurityFileSelector());

Expand Down Expand Up @@ -351,6 +348,15 @@ protected Archiver createArchiver(
return archiver;
}

private void configureJarArchiver(JarArchiver archiver, String mergeManifestMode) {

if (mergeManifestMode != null) {
archiver.setFilesetmanifest(JarArchiver.FilesetManifestConfig.valueOf(mergeManifestMode));
}

archiver.setMinimalDefaultManifest(true);
}

private void configureContainerDescriptorHandler(
final ContainerDescriptorHandler handler,
final Xpp3Dom config,
Expand Down

0 comments on commit 2d61b0f

Please sign in to comment.