You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2024/12/06 16:05:48 UTC

(maven-dependency-plugin) branch master updated: [MDEP-952] Remove StringUtils dependency (#492)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new ae19d893 [MDEP-952] Remove StringUtils dependency (#492)
ae19d893 is described below

commit ae19d893bb61a4b8414877721ca25b580c454dad
Author: Elliotte Rusty Harold <el...@users.noreply.github.com>
AuthorDate: Fri Dec 6 16:05:43 2024 +0000

    [MDEP-952] Remove StringUtils dependency (#492)
    
    * Remove StringUtils dependency
---
 .../plugins/dependency/utils/filters/DestFileFilter.java    |  7 +++----
 .../dependency/utils/markers/UnpackFileMarkerHandler.java   | 13 ++++++-------
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java b/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java
index be52f1f5..669c90c1 100644
--- a/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java
+++ b/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java
@@ -24,7 +24,6 @@ import java.nio.file.Files;
 import java.util.LinkedHashSet;
 import java.util.Set;
 
-import org.apache.commons.lang3.StringUtils;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem;
 import org.apache.maven.plugins.dependency.utils.DependencyUtil;
@@ -284,7 +283,7 @@ public class DestFileFilter extends AbstractArtifactsFilter implements ArtifactI
         }
 
         File destFile;
-        if (StringUtils.isEmpty(item.getDestFileName())) {
+        if (item.getDestFileName() == null || item.getDestFileName().isEmpty()) {
             String formattedFileName = DependencyUtil.getFormattedFileName(
                     artifact, removeVersion, prependGroupId, useBaseVersion, removeClassifier);
             destFile = new File(destFolder, formattedFileName);
@@ -298,13 +297,13 @@ public class DestFileFilter extends AbstractArtifactsFilter implements ArtifactI
     }
 
     /**
-     * Using simply {@code File.getLastModified} will return sometimes a wrong value see JDK bug for details.
+     * {@code File.getLastModified} sometimes returns a wrong value. See JDK bug for details.
      * <p>
      * https://bugs.openjdk.java.net/browse/JDK-8177809
      *
      * @param file {@link File}
      * @return the last modification time in milliseconds.
-     * @throws ArtifactFilterException in case of a IO Exception.
+     * @throws ArtifactFilterException in case of an IOException
      */
     private long getLastModified(File file) throws ArtifactFilterException {
         try {
diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java
index 00c7be06..396f39fc 100644
--- a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java
+++ b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java
@@ -20,7 +20,6 @@ package org.apache.maven.plugins.dependency.utils.markers;
 
 import java.io.File;
 
-import org.apache.commons.lang3.StringUtils;
 import org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem;
 
 /**
@@ -52,22 +51,22 @@ public class UnpackFileMarkerHandler extends DefaultFileMarkerHandler {
     protected File getMarkerFile() {
         /*
          * Build a hash of all include/exclude strings, to determine if an artifactItem has been unpacked using the
-         * include/exclude parameters, this will allow an artifact to be included multiple times with different
-         * include/exclude parameters
+         * include/exclude parameters. This allows an artifact to be included multiple times with different
+         * include/exclude parameters.
          */
         File markerFile;
         if (this.artifactItem == null
-                || (StringUtils.isEmpty(this.artifactItem.getIncludes())
-                        && StringUtils.isEmpty(this.artifactItem.getExcludes()))) {
+                || this.artifactItem.getIncludes().isEmpty()
+                        && this.artifactItem.getExcludes().isEmpty()) {
             markerFile = super.getMarkerFile();
         } else {
             int includeExcludeHash = 0;
 
-            if (StringUtils.isNotEmpty(this.artifactItem.getIncludes())) {
+            if (!this.artifactItem.getIncludes().isEmpty()) {
                 includeExcludeHash += this.artifactItem.getIncludes().hashCode();
             }
 
-            if (StringUtils.isNotEmpty(this.artifactItem.getExcludes())) {
+            if (!this.artifactItem.getExcludes().isEmpty()) {
                 includeExcludeHash += this.artifactItem.getExcludes().hashCode();
             }