Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
elharo committed Nov 28, 2024
2 parents 8074adf + 0079030 commit d90c468
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 44 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ under the License.
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>
<scope>provided</scope>
</dependency>

<!-- doxia -->
<dependency>
<groupId>org.apache.maven.doxia</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.Map;
import java.util.Set;

import org.apache.commons.lang3.StringUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.plugin.AbstractMojo;
Expand Down Expand Up @@ -512,7 +511,7 @@ private void writeDependencyXML(Set<Artifact> artifacts) {
writer.startElement("version");
writer.writeText(artifact.getBaseVersion());
String classifier = artifact.getClassifier();
if (StringUtils.isNotBlank(classifier)) {
if (classifier != null && !classifier.trim().isEmpty()) {
writer.startElement("classifier");
writer.writeText(artifact.getClassifier());
writer.endElement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement;
Expand Down Expand Up @@ -146,7 +145,7 @@ private boolean checkDependencyManagement() throws MojoExecutionException {
// log exclusion errors
List<Artifact> exclusionErrors = getExclusionErrors(exclusions, allDependencyArtifacts);
for (Artifact exclusion : exclusionErrors) {
getLog().info(StringUtils.stripEnd(getArtifactManagementKey(exclusion), ":")
getLog().info(getArtifactManagementKey(exclusion)
+ " was excluded in DepMgt, but version " + exclusion.getVersion()
+ " has been found in the dependency tree.");
foundError = true;
Expand Down Expand Up @@ -249,7 +248,7 @@ public void logMismatch(Artifact dependencyArtifact, Dependency dependencyFromDe
"Invalid params: Artifact: " + dependencyArtifact + " Dependency: " + dependencyFromDepMgt);
}

getLog().info("\tDependency: " + StringUtils.stripEnd(dependencyFromDepMgt.getManagementKey(), ":"));
getLog().info("\tDependency: " + dependencyFromDepMgt.getManagementKey());
getLog().info("\t\tDepMgt : " + dependencyFromDepMgt.getVersion());
getLog().info("\t\tResolved: " + dependencyArtifact.getBaseVersion());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,14 @@ protected List<ArtifactItem> getProcessedArtifactItems(ProcessArtifactItemsReque
artifactItem.getOutputDirectory().mkdirs();

// make sure we have a version.
if (StringUtils.isEmpty(artifactItem.getVersion())) {
if (artifactItem.getVersion() == null || artifactItem.getVersion().isEmpty()) {
fillMissingArtifactVersion(artifactItem);
}

artifactItem.setArtifact(this.getArtifact(artifactItem));

if (StringUtils.isEmpty(artifactItem.getDestFileName())) {
if (artifactItem.getDestFileName() == null
|| artifactItem.getDestFileName().length() == 0) {
artifactItem.setDestFileName(DependencyUtil.getFormattedFileName(
artifactItem.getArtifact(), removeVersion, prependGroupId, useBaseVersion, removeClassifier));
}
Expand All @@ -185,7 +186,7 @@ protected List<ArtifactItem> getProcessedArtifactItems(ProcessArtifactItemsReque
}

private boolean checkIfProcessingNeeded(ArtifactItem item) throws MojoExecutionException, ArtifactFilterException {
return StringUtils.equalsIgnoreCase(item.getOverWrite(), "true")
return "true".equalsIgnoreCase(item.getOverWrite())
|| getMarkedArtifactFilter(item).isArtifactIncluded(item);
}

Expand Down Expand Up @@ -216,6 +217,7 @@ protected Artifact getArtifact(ArtifactItem artifactItem) throws MojoExecutionEx
coordinate.setClassifier(artifactItem.getClassifier());

final String extension;

ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler(artifactItem.getType());
if (artifactHandler != null) {
extension = artifactHandler.getExtension();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.io.File;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
Expand Down Expand Up @@ -170,10 +169,10 @@ protected List<ArtifactItem> getProcessedArtifactItems(boolean removeVersion) th
List<ArtifactItem> items =
super.getProcessedArtifactItems(new ProcessArtifactItemsRequest(removeVersion, false, false, false));
for (ArtifactItem artifactItem : items) {
if (StringUtils.isEmpty(artifactItem.getIncludes())) {
if (artifactItem.getIncludes().isEmpty()) {
artifactItem.setIncludes(getIncludes());
}
if (StringUtils.isEmpty(artifactItem.getExcludes())) {
if (artifactItem.getExcludes().isEmpty()) {
artifactItem.setExcludes(getExcludes());
}
}
Expand Down
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 d90c468

Please sign in to comment.