From f186993414e076abcf70b960b487813a6b1df8b7 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 15 May 2023 23:44:50 +0200 Subject: [PATCH] [MSOURCES-135] Cleanup project code - fix dependencies according to output of dependency:analyze - bump plexus-utils to 3.5.1 - don't use deprecated methods --- pom.xml | 20 ++++++++++++++----- src/it/reproducible/verify.groovy | 3 ++- .../plugins/source/AbstractSourceJarMojo.java | 15 +++++++------- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index e29db42..fd3f046 100644 --- a/pom.xml +++ b/pom.xml @@ -82,6 +82,16 @@ under the License. 2019-12-16T18:10:36Z + + + + commons-io + commons-io + 2.11.0 + + + + org.apache.maven @@ -122,13 +132,13 @@ under the License. org.codehaus.plexus - plexus-utils - 3.4.2 + plexus-archiver + 4.7.1 - commons-io - commons-io - 2.11.0 + org.codehaus.plexus + plexus-utils + 3.5.1 diff --git a/src/it/reproducible/verify.groovy b/src/it/reproducible/verify.groovy index 19b8af7..8c11d18 100644 --- a/src/it/reproducible/verify.groovy +++ b/src/it/reproducible/verify.groovy @@ -82,4 +82,5 @@ zipFile.close(); String buf = r.toString() println buf -assert buf.startsWith( "reproducible-1.0-sources.jar sha1 = f159379802c1f0dc1083af21352286b09d364519" ) +// on Windows executable bit is not set +assert buf.startsWith( "reproducible-1.0-sources.jar sha1 = f159379802c1f0dc1083af21352286b09d364519" ) || buf.startsWith( "reproducible-1.0-sources.jar sha1 = e14cb3b37b6d82db1728886d1959ad0cd79708d8" ) diff --git a/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java b/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java index 52c0d75..f624be7 100644 --- a/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java +++ b/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java @@ -41,6 +41,7 @@ import org.codehaus.plexus.archiver.ArchiverException; import org.codehaus.plexus.archiver.jar.JarArchiver; import org.codehaus.plexus.archiver.jar.ManifestException; +import org.codehaus.plexus.archiver.util.DefaultFileSet; import org.codehaus.plexus.util.FileUtils; /** @@ -420,8 +421,7 @@ protected void addDirectory(Archiver archiver, File sourceDirectory, String[] pI throws MojoExecutionException { try { getLog().debug("add directory " + sourceDirectory + " to archiver"); - // archiver.addFileSet( fileSet ); - archiver.addDirectory(sourceDirectory, pIncludes, pExcludes); + archiver.addFileSet(DefaultFileSet.fileSet(sourceDirectory).includeExclude(pIncludes, pExcludes)); } catch (ArchiverException e) { throw new MojoExecutionException("Error adding directory to source archive.", e); } @@ -440,7 +440,8 @@ protected void addDirectory( throws MojoExecutionException { try { getLog().debug("add directory " + sourceDirectory + " to archiver with prefix " + prefix); - archiver.addDirectory(sourceDirectory, prefix, pIncludes, pExcludes); + archiver.addFileSet( + DefaultFileSet.fileSet(sourceDirectory).prefixed(prefix).includeExclude(pIncludes, pExcludes)); } catch (ArchiverException e) { throw new MojoExecutionException("Error adding directory to source archive.", e); } @@ -486,12 +487,12 @@ private String[] getCombinedIncludes(List additionalIncludes) { combinedIncludes.addAll(Arrays.asList(includes)); } - if (additionalIncludes != null && additionalIncludes.size() > 0) { + if (additionalIncludes != null && !additionalIncludes.isEmpty()) { combinedIncludes.addAll(additionalIncludes); } // If there are no other includes, use the default. - if (combinedIncludes.size() == 0) { + if (combinedIncludes.isEmpty()) { combinedIncludes.addAll(Arrays.asList(DEFAULT_INCLUDES)); } @@ -516,11 +517,11 @@ private String[] getCombinedExcludes(List additionalExcludes) { combinedExcludes.addAll(Arrays.asList(excludes)); } - if (additionalExcludes != null && additionalExcludes.size() > 0) { + if (additionalExcludes != null && !additionalExcludes.isEmpty()) { combinedExcludes.addAll(additionalExcludes); } - if (combinedExcludes.size() == 0) { + if (combinedExcludes.isEmpty()) { combinedExcludes.addAll(Arrays.asList(DEFAULT_EXCLUDES)); }