You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2023/05/17 21:15:31 UTC

[maven-source-plugin] branch master updated: [MSOURCES-135] Cleanup project code

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

sjaranowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-source-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new f186993  [MSOURCES-135] Cleanup project code
f186993 is described below

commit f186993414e076abcf70b960b487813a6b1df8b7
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Mon May 15 23:44:50 2023 +0200

    [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 ++-
 .../maven/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.
     <project.build.outputTimestamp>2019-12-16T18:10:36Z</project.build.outputTimestamp>
   </properties>
 
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>commons-io</groupId>
+        <artifactId>commons-io</artifactId>
+        <version>2.11.0</version>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
   <dependencies>
     <dependency>
       <groupId>org.apache.maven</groupId>
@@ -122,13 +132,13 @@ under the License.
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-utils</artifactId>
-      <version>3.4.2</version>
+      <artifactId>plexus-archiver</artifactId>
+      <version>4.7.1</version>
     </dependency>
     <dependency>
-      <groupId>commons-io</groupId>
-      <artifactId>commons-io</artifactId>
-      <version>2.11.0</version>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>3.5.1</version>
     </dependency>
 
     <dependency>
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.Archiver;
 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 @@ public abstract class AbstractSourceJarMojo extends AbstractMojo {
             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 @@ public abstract class AbstractSourceJarMojo extends AbstractMojo {
             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 @@ public abstract class AbstractSourceJarMojo extends AbstractMojo {
             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 @@ public abstract class AbstractSourceJarMojo extends AbstractMojo {
             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));
         }