Skip to content

Commit

Permalink
[MDEP-952] Decouple DependencyUtil from StringUtils (#491)
Browse files Browse the repository at this point in the history
* Decouple DependencyUtil from StringUtils
  • Loading branch information
elharo authored Nov 28, 2024
1 parent eceab09 commit 0079030
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.nio.file.StandardOpenOption;
import java.util.Objects;

import org.apache.commons.lang3.StringUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.plugin.logging.Log;
Expand Down Expand Up @@ -119,7 +118,9 @@ public static String getFormattedFileName(

String classifierString = "";

if (!removeClassifier && StringUtils.isNotEmpty(artifact.getClassifier())) {
if (!removeClassifier
&& artifact.getClassifier() != null
&& !artifact.getClassifier().isEmpty()) {
classifierString = "-" + artifact.getClassifier();
}
destFileName.append(artifact.getArtifactId()).append(versionString);
Expand Down Expand Up @@ -186,7 +187,7 @@ private static String getDependencyId(Artifact artifact, boolean removeVersion,
sb.append(artifact.getVersion());
}

if (StringUtils.isNotEmpty(artifact.getClassifier())) {
if (artifact.getClassifier() != null && !artifact.getClassifier().isEmpty()) {
sb.append("-");
sb.append(artifact.getClassifier());
}
Expand Down Expand Up @@ -259,16 +260,6 @@ public static synchronized void log(String string, Log log) throws IOException {
}
}

/**
* Mainly used to parse excludes, includes configuration.
*
* @param str the string to split
* @return the result items
*/
public static String[] tokenizer(String str) {
return StringUtils.split(cleanToBeTokenizedString(str), ",");
}

/**
* Clean up configuration string before it can be tokenized.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,26 +320,6 @@ void testFileNameClassifierWithFile() {
assertEquals(expectedResult, name);
}

@Test
void testTokenizer() {
String[] tokens = DependencyUtil.tokenizer(" alpha,bravo, charlie , delta kappa, theta");
String[] expected = new String[] {"alpha", "bravo", "charlie", "delta kappa", "theta"};
// easier to see in the JUnit reports
assertEquals(String.join(", ", expected), String.join(", ", tokens));
assertEquals(expected.length, tokens.length);

tokens = DependencyUtil.tokenizer(" \r\n a, \t \n \r b \t \n \r");
assertEquals(2, tokens.length);
assertEquals("a", tokens[0]);
assertEquals("b", tokens[1]);

tokens = DependencyUtil.tokenizer(null);
assertEquals(0, tokens.length);

tokens = DependencyUtil.tokenizer(" ");
assertEquals(0, tokens.length);
}

@Test
void outputFileShouldBeOverridden() throws IOException {
File file = new File(temDir, "file1.out");
Expand Down

0 comments on commit 0079030

Please sign in to comment.