Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MDEP-952] Decouple DependencyUtil from StringUtils #491

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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