diff --git a/maven-artifact/pom.xml b/maven-artifact/pom.xml
index 3059992da6..a7459b8432 100644
--- a/maven-artifact/pom.xml
+++ b/maven-artifact/pom.xml
@@ -30,13 +30,6 @@ under the License.
Maven Artifact
-
-
- org.apache.commons
- commons-lang3
-
-
-
diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java b/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java
index 2b44cf3f74..8ea6710a56 100644
--- a/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java
+++ b/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java
@@ -25,7 +25,6 @@ import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
-import org.apache.commons.lang3.Validate;
import org.apache.maven.artifact.versioning.VersionRange;
/**
@@ -89,10 +88,15 @@ public final class ArtifactUtils {
}
private static void notBlank(String str, String message) {
- int c = str != null && str.length() > 0 ? str.charAt(0) : 0;
- if ((c < '0' || c > '9') && (c < 'a' || c > 'z')) {
- Validate.notBlank(str, message);
+ final int strLen = str != null ? str.length() : 0;
+ if (strLen > 0) {
+ for (int i = 0; i < strLen; i++) {
+ if (!Character.isWhitespace(str.charAt(i))) {
+ return;
+ }
+ }
}
+ throw new IllegalArgumentException(message);
}
public static Map artifactMapByVersionlessId(Collection artifacts) {
diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/DefaultArtifactVersion.java b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/DefaultArtifactVersion.java
index 10da535c15..ceaab0a77e 100644
--- a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/DefaultArtifactVersion.java
+++ b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/DefaultArtifactVersion.java
@@ -20,8 +20,6 @@ package org.apache.maven.artifact.versioning;
import java.util.StringTokenizer;
-import static org.apache.commons.lang3.math.NumberUtils.isDigits;
-
/**
* Default implementation of artifact versioning.
*
@@ -168,6 +166,19 @@ public class DefaultArtifactVersion implements ArtifactVersion {
}
}
+ private static boolean isDigits(String cs) {
+ if (cs == null || cs.isEmpty()) {
+ return false;
+ }
+ final int sz = cs.length();
+ for (int i = 0; i < sz; i++) {
+ if (!Character.isDigit(cs.charAt(i))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
private static Integer getNextIntegerToken(StringTokenizer tok) {
String s = tok.nextToken();
if ((s.length() > 1) && s.startsWith("0")) {
diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataBridge.java b/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataBridge.java
index 48eea0ac53..1ad0d487ee 100644
--- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataBridge.java
+++ b/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataBridge.java
@@ -19,10 +19,10 @@
package org.apache.maven.artifact.repository.metadata;
import java.io.File;
+import java.nio.file.Files;
import java.util.Collections;
import java.util.Map;
-import org.apache.commons.io.FileUtils;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
@@ -50,7 +50,8 @@ public final class MetadataBridge extends AbstractMetadata implements MergeableM
public void merge(File current, File result) throws RepositoryException {
try {
if (current.exists()) {
- FileUtils.copyFile(current, result);
+ Files.createDirectories(result.toPath().getParent());
+ Files.copy(current.toPath(), result.toPath());
}
ArtifactRepository localRepo = new MetadataRepository(result);
metadata.storeInLocalRepository(localRepo, localRepo);
diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java
index 29bf7494f2..d34af30fdd 100644
--- a/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java
@@ -21,8 +21,9 @@ package org.apache.maven.artifact.deployer;
import javax.inject.Inject;
import java.io.File;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
-import org.apache.commons.io.FileUtils;
import org.apache.maven.artifact.AbstractArtifactComponentTestCase;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -60,15 +61,14 @@ public class ArtifactDeployerTest extends AbstractArtifactComponentTestCase {
Artifact artifact = createArtifact("artifact", "1.0");
File file = new File(artifactBasedir, "artifact-1.0.jar");
- assertEquals("dummy", FileUtils.readFileToString(file, "UTF-8").trim());
+ assertEquals("dummy", new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8).trim());
artifactDeployer.deploy(file, artifact, remoteRepository(), localRepository());
ArtifactRepository remoteRepository = remoteRepository();
File deployedFile = new File(remoteRepository.getBasedir(), remoteRepository.pathOf(artifact));
assertTrue(deployedFile.exists());
- assertEquals(
- "dummy", FileUtils.readFileToString(deployedFile, "UTF-8").trim());
+ assertEquals("dummy", new String(Files.readAllBytes(deployedFile.toPath()), StandardCharsets.UTF_8).trim());
} finally {
sessionScope.exit();
}
diff --git a/maven-core/pom.xml b/maven-core/pom.xml
index abc40b5491..3c6f5bc35a 100644
--- a/maven-core/pom.xml
+++ b/maven-core/pom.xml
@@ -123,10 +123,6 @@ under the License.
com.google.guava
failureaccess
-
- commons-io
- commons-io
-
javax.inject
javax.inject
@@ -140,10 +136,6 @@ under the License.
org.codehaus.plexus
plexus-classworlds
-
- org.apache.commons
- commons-lang3
-
org.slf4j
slf4j-api
@@ -158,6 +150,11 @@ under the License.
commons-jxpath
test
+
+ commons-io
+ commons-io
+ test
+
org.mockito
mockito-core
diff --git a/maven-core/src/main/java/org/apache/maven/configuration/DefaultBeanConfigurationRequest.java b/maven-core/src/main/java/org/apache/maven/configuration/DefaultBeanConfigurationRequest.java
index 5e5291c1ff..b1deeb00ec 100644
--- a/maven-core/src/main/java/org/apache/maven/configuration/DefaultBeanConfigurationRequest.java
+++ b/maven-core/src/main/java/org/apache/maven/configuration/DefaultBeanConfigurationRequest.java
@@ -18,13 +18,13 @@
*/
package org.apache.maven.configuration;
-import org.apache.commons.lang3.Validate;
+import java.util.Objects;
+
import org.apache.maven.model.Build;
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginExecution;
import org.apache.maven.model.PluginManagement;
-import org.codehaus.plexus.util.StringUtils;
/**
* A basic bean configuration request.
@@ -89,7 +89,7 @@ public class DefaultBeanConfigurationRequest implements BeanConfigurationRequest
Model model, String pluginGroupId, String pluginArtifactId, String pluginExecutionId) {
Plugin plugin = findPlugin(model, pluginGroupId, pluginArtifactId);
if (plugin != null) {
- if (StringUtils.isNotEmpty(pluginExecutionId)) {
+ if (pluginExecutionId != null && !pluginExecutionId.isEmpty()) {
for (PluginExecution execution : plugin.getExecutions()) {
if (pluginExecutionId.equals(execution.getId())) {
setConfiguration(execution.getConfiguration());
@@ -104,8 +104,12 @@ public class DefaultBeanConfigurationRequest implements BeanConfigurationRequest
}
private Plugin findPlugin(Model model, String groupId, String artifactId) {
- Validate.notBlank(groupId, "groupId can neither be null, empty nor blank");
- Validate.notBlank(artifactId, "artifactId can neither be null, empty nor blank");
+ if (Objects.requireNonNull(groupId, "groupId cannot be null").isEmpty()) {
+ throw new IllegalArgumentException("groupId cannot be empty");
+ }
+ if (Objects.requireNonNull(artifactId, "artifactId cannot be null").isEmpty()) {
+ throw new IllegalArgumentException("artifactId cannot be empty");
+ }
if (model != null) {
Build build = model.getBuild();
diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultBuildResumptionDataRepository.java b/maven-core/src/main/java/org/apache/maven/execution/DefaultBuildResumptionDataRepository.java
index a518783640..8a4ded84fb 100644
--- a/maven-core/src/main/java/org/apache/maven/execution/DefaultBuildResumptionDataRepository.java
+++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultBuildResumptionDataRepository.java
@@ -30,7 +30,6 @@ import java.nio.file.Paths;
import java.util.Properties;
import java.util.stream.Stream;
-import org.apache.commons.lang3.StringUtils;
import org.apache.maven.project.MavenProject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -109,10 +108,11 @@ public class DefaultBuildResumptionDataRepository implements BuildResumptionData
// This method is made package-private for testing purposes
void applyResumptionProperties(MavenExecutionRequest request, Properties properties) {
- if (properties.containsKey(REMAINING_PROJECTS) && StringUtils.isEmpty(request.getResumeFrom())) {
+ String str1 = request.getResumeFrom();
+ if (properties.containsKey(REMAINING_PROJECTS) && !(str1 != null && !str1.isEmpty())) {
String propertyValue = properties.getProperty(REMAINING_PROJECTS);
Stream.of(propertyValue.split(PROPERTY_DELIMITER))
- .filter(StringUtils::isNotEmpty)
+ .filter(str -> str != null && !str.isEmpty())
.forEach(request.getProjectActivation()::activateOptionalProject);
LOGGER.info("Resuming from {} due to the --resume / -r feature.", propertyValue);
}
diff --git a/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultArtifactCoordinateFactory.java b/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultArtifactCoordinateFactory.java
index 1df33dd898..3b2a165847 100644
--- a/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultArtifactCoordinateFactory.java
+++ b/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultArtifactCoordinateFactory.java
@@ -21,7 +21,6 @@ package org.apache.maven.internal.impl;
import javax.inject.Named;
import javax.inject.Singleton;
-import org.apache.commons.lang3.StringUtils;
import org.apache.maven.api.ArtifactCoordinate;
import org.apache.maven.api.annotations.Nonnull;
import org.apache.maven.api.services.ArtifactCoordinateFactory;
@@ -43,12 +42,12 @@ public class DefaultArtifactCoordinateFactory implements ArtifactCoordinateFacto
if (request.getType() != null) {
type = session.getSession().getArtifactTypeRegistry().get(request.getType());
}
- String classifier = StringUtils.isNotEmpty(request.getClassifier())
- ? request.getClassifier()
- : type != null ? type.getClassifier() : "";
- String extension = StringUtils.isNotEmpty(request.getExtension())
- ? request.getExtension()
- : type != null ? type.getExtension() : "";
+ String str1 = request.getClassifier();
+ String classifier =
+ str1 != null && !str1.isEmpty() ? request.getClassifier() : type != null ? type.getClassifier() : "";
+ String str = request.getExtension();
+ String extension =
+ str != null && !str.isEmpty() ? request.getExtension() : type != null ? type.getExtension() : "";
return new DefaultArtifactCoordinate(
session,
new org.eclipse.aether.artifact.DefaultArtifact(
diff --git a/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultArtifactFactory.java b/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultArtifactFactory.java
index f03a9cebbe..2788b77284 100644
--- a/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultArtifactFactory.java
+++ b/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultArtifactFactory.java
@@ -21,7 +21,6 @@ package org.apache.maven.internal.impl;
import javax.inject.Named;
import javax.inject.Singleton;
-import org.apache.commons.lang3.StringUtils;
import org.apache.maven.api.Artifact;
import org.apache.maven.api.annotations.Nonnull;
import org.apache.maven.api.services.ArtifactFactory;
@@ -43,12 +42,12 @@ public class DefaultArtifactFactory implements ArtifactFactory {
if (request.getType() != null) {
type = session.getSession().getArtifactTypeRegistry().get(request.getType());
}
- String classifier = StringUtils.isNotEmpty(request.getClassifier())
- ? request.getClassifier()
- : type != null ? type.getClassifier() : null;
- String extension = StringUtils.isNotEmpty(request.getExtension())
- ? request.getExtension()
- : type != null ? type.getExtension() : null;
+ String str1 = request.getClassifier();
+ String classifier =
+ str1 != null && !str1.isEmpty() ? request.getClassifier() : type != null ? type.getClassifier() : null;
+ String str = request.getExtension();
+ String extension =
+ str != null && !str.isEmpty() ? request.getExtension() : type != null ? type.getExtension() : null;
return new DefaultArtifact(
session,
new org.eclipse.aether.artifact.DefaultArtifact(
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/MavenPluginJavaPrerequisiteChecker.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/MavenPluginJavaPrerequisiteChecker.java
index 64406fe48c..a100c349a0 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/internal/MavenPluginJavaPrerequisiteChecker.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/MavenPluginJavaPrerequisiteChecker.java
@@ -24,7 +24,6 @@ import javax.inject.Singleton;
import org.apache.maven.plugin.MavenPluginPrerequisitesChecker;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
-import org.codehaus.plexus.util.StringUtils;
import org.eclipse.aether.version.InvalidVersionSpecificationException;
import org.eclipse.aether.version.Version;
import org.eclipse.aether.version.VersionConstraint;
@@ -44,7 +43,7 @@ public class MavenPluginJavaPrerequisiteChecker implements MavenPluginPrerequisi
@Override
public void accept(PluginDescriptor pluginDescriptor) {
String requiredJavaVersion = pluginDescriptor.getRequiredJavaVersion();
- if (StringUtils.isNotBlank(requiredJavaVersion)) {
+ if (requiredJavaVersion != null && !requiredJavaVersion.isEmpty()) {
String currentJavaVersion = System.getProperty("java.version");
if (!matchesVersion(requiredJavaVersion, currentJavaVersion)) {
throw new IllegalStateException("Required Java version " + requiredJavaVersion
diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/ProjectArtifactMetadata.java b/maven-core/src/main/java/org/apache/maven/project/artifact/ProjectArtifactMetadata.java
index f00cb4b2b7..4a349330ea 100644
--- a/maven-core/src/main/java/org/apache/maven/project/artifact/ProjectArtifactMetadata.java
+++ b/maven-core/src/main/java/org/apache/maven/project/artifact/ProjectArtifactMetadata.java
@@ -20,8 +20,8 @@ package org.apache.maven.project.artifact;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Files;
-import org.apache.commons.io.FileUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.AbstractArtifactMetadata;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
@@ -74,7 +74,8 @@ public class ProjectArtifactMetadata extends AbstractArtifactMetadata {
// ----------------------------------------------------------------------------
try {
- FileUtils.copyFile(file, destination);
+ Files.createDirectories(destination.toPath().getParent());
+ Files.copy(file.toPath(), destination.toPath());
} catch (IOException e) {
throw new RepositoryMetadataStoreException("Error copying POM to the local repository.", e);
}
diff --git a/maven-core/src/main/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformation.java b/maven-core/src/main/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformation.java
index ac5d18d7c3..9211c615ff 100644
--- a/maven-core/src/main/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformation.java
+++ b/maven-core/src/main/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformation.java
@@ -24,10 +24,9 @@ import javax.inject.Singleton;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Objects;
import java.util.Properties;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.Validate;
import org.apache.maven.rtinfo.RuntimeInformation;
import org.eclipse.aether.version.InvalidVersionSpecificationException;
import org.eclipse.aether.version.Version;
@@ -90,7 +89,9 @@ public class DefaultRuntimeInformation implements RuntimeInformation {
@Override
public boolean isMavenVersion(String versionRange) {
- Validate.notBlank(versionRange, "versionRange can neither be null, empty nor blank");
+ if (Objects.requireNonNull(versionRange, "versionRange cannot be null").isEmpty()) {
+ throw new IllegalArgumentException("versionRange cannot be empty");
+ }
VersionConstraint constraint;
try {
@@ -102,7 +103,9 @@ public class DefaultRuntimeInformation implements RuntimeInformation {
Version current;
try {
String mavenVersion = getMavenVersion();
- Validate.validState(StringUtils.isNotEmpty(mavenVersion), "Could not determine current Maven version");
+ if (mavenVersion.isEmpty()) {
+ throw new IllegalArgumentException("Could not determine current Maven version");
+ }
current = versionScheme.parseVersion(mavenVersion);
} catch (InvalidVersionSpecificationException e) {
diff --git a/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java b/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java
index bc062ee882..f425184746 100644
--- a/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java
+++ b/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java
@@ -21,9 +21,9 @@ package org.apache.maven.artifact.handler;
import javax.inject.Inject;
import java.io.File;
+import java.nio.file.Files;
import java.util.List;
-import org.apache.commons.io.FileUtils;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.testing.PlexusTest;
import org.junit.jupiter.api.Test;
@@ -40,7 +40,7 @@ public class ArtifactHandlerTest {
public void testAptConsistency() throws Exception {
File apt = getTestFile("src/site/apt/artifact-handlers.apt");
- List lines = FileUtils.readLines(apt);
+ List lines = Files.readAllLines(apt.toPath());
for (String line : lines) {
if (line.startsWith("||")) {
diff --git a/maven-core/src/test/java/org/apache/maven/internal/impl/TestRepositorySystem.java b/maven-core/src/test/java/org/apache/maven/internal/impl/TestRepositorySystem.java
index 3f3d1e08a7..3201e752d1 100644
--- a/maven-core/src/test/java/org/apache/maven/internal/impl/TestRepositorySystem.java
+++ b/maven-core/src/test/java/org/apache/maven/internal/impl/TestRepositorySystem.java
@@ -24,12 +24,12 @@ import javax.inject.Singleton;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Files;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.apache.commons.io.FileUtils;
import org.apache.maven.api.model.Model;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
@@ -274,7 +274,8 @@ public class TestRepositorySystem implements RepositorySystem {
File remoteFile = new File(remoteRepo.getBasedir(), remoteRepo.pathOf(artifact));
- FileUtils.copyFile(remoteFile, localFile);
+ Files.createDirectories(localFile.toPath().getParent());
+ Files.copy(remoteFile.toPath(), localFile.toPath());
}
artifact.setResolved(true);
diff --git a/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java b/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
index 7d34788d71..e431b5cc3f 100644
--- a/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
+++ b/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
@@ -19,6 +19,8 @@
package org.apache.maven.project;
import java.io.File;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
@@ -178,11 +180,11 @@ public class ProjectBuilderTest extends AbstractCoreMavenComponentTestCase {
projectBuilder.build(child, configuration);
// modify parent
File parent = new File(tempDir.toFile(), "pom.xml");
- String parentContent = FileUtils.readFileToString(parent, "UTF-8");
+ String parentContent = new String(Files.readAllBytes(parent.toPath()), StandardCharsets.UTF_8);
parentContent = parentContent.replace(
"pom",
"pomaddedValue");
- FileUtils.write(parent, parentContent, "UTF-8");
+ Files.write(parent.toPath(), parentContent.getBytes(StandardCharsets.UTF_8));
// re-build pom with modified parent
ProjectBuildingResult result = projectBuilder.build(child, configuration);
assertThat(result.getProject().getProperties(), hasKey((Object) "addedProperty"));
diff --git a/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnector.java b/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnector.java
index 6f9d963904..9b8214121c 100644
--- a/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnector.java
+++ b/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnector.java
@@ -22,9 +22,10 @@ import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.Collection;
-import org.apache.commons.io.FileUtils;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.metadata.Metadata;
import org.eclipse.aether.repository.RemoteRepository;
@@ -50,7 +51,10 @@ public class TestRepositoryConnector implements RepositoryConnector {
public TestRepositoryConnector(RemoteRepository repository) {
this.repository = repository;
try {
- basedir = FileUtils.toFile(new URL(repository.getUrl()));
+ URL url = new URL(repository.getUrl());
+ if ("file".equals(url.getProtocol())) {
+ basedir = new File(url.getPath());
+ }
} catch (MalformedURLException e) {
throw new IllegalStateException(e);
}
@@ -65,7 +69,9 @@ public class TestRepositoryConnector implements RepositoryConnector {
for (ArtifactDownload download : artifactDownloads) {
File remoteFile = new File(basedir, path(download.getArtifact()));
try {
- FileUtils.copyFile(remoteFile, download.getFile());
+ Path dest = download.getFile().toPath();
+ Files.createDirectories(dest.getParent());
+ Files.copy(remoteFile.toPath(), dest);
} catch (IOException e) {
if (!remoteFile.exists()) {
download.setException(new ArtifactNotFoundException(download.getArtifact(), repository));
@@ -79,7 +85,9 @@ public class TestRepositoryConnector implements RepositoryConnector {
for (final MetadataDownload download : metadataDownloads) {
File remoteFile = new File(basedir, path(download.getMetadata()));
try {
- FileUtils.copyFile(remoteFile, download.getFile());
+ Path dest = download.getFile().toPath();
+ Files.createDirectories(dest.getParent());
+ Files.copy(remoteFile.toPath(), dest);
} catch (IOException e) {
if (!remoteFile.exists()) {
download.setException(new MetadataNotFoundException(download.getMetadata(), repository));
diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml
index 5d8bcf9887..957d2d79a4 100644
--- a/maven-embedder/pom.xml
+++ b/maven-embedder/pom.xml
@@ -146,10 +146,6 @@ under the License.
commons-cli
commons-cli
-
- org.apache.commons
- commons-lang3
-
org.mockito
mockito-core
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java b/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java
index d3f5695d4d..bc879c6409 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java
@@ -25,7 +25,6 @@ import java.util.Date;
import java.util.Locale;
import java.util.Properties;
-import org.apache.commons.lang3.StringUtils;
import org.codehaus.plexus.util.Os;
import org.slf4j.Logger;
@@ -106,7 +105,7 @@ public final class CLIReportingUtils {
if (rev != null || timestamp != null) {
msg += " (";
msg += (rev != null ? rev : "");
- if (StringUtils.isNotBlank(timestamp)) {
+ if (timestamp != null && !timestamp.isEmpty()) {
String ts = formatTimestamp(Long.parseLong(timestamp));
msg += (rev != null ? "; " : "") + ts;
}
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java
index 514538bed1..f1e84d8c8e 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java
@@ -23,7 +23,6 @@ import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
-import org.apache.commons.lang3.Validate;
import org.eclipse.aether.transfer.AbstractTransferListener;
import org.eclipse.aether.transfer.TransferCancelledException;
import org.eclipse.aether.transfer.TransferEvent;
@@ -100,7 +99,9 @@ public abstract class AbstractMavenTransferListener extends AbstractTransferList
public abstract String symbol();
public static ScaleUnit getScaleUnit(long size) {
- Validate.isTrue(size >= 0L, "file size cannot be negative: %s", size);
+ if (size < 0L) {
+ throw new IllegalArgumentException("file size cannot be negative: " + size);
+ }
if (size >= GIGABYTE.bytes()) {
return GIGABYTE;
@@ -132,7 +133,9 @@ public abstract class AbstractMavenTransferListener extends AbstractTransferList
@SuppressWarnings("checkstyle:magicnumber")
public String format(long size, ScaleUnit unit, boolean omitSymbol) {
- Validate.isTrue(size >= 0L, "file size cannot be negative: %s", size);
+ if (size < 0L) {
+ throw new IllegalArgumentException("file size cannot be negative: " + size);
+ }
if (unit == null) {
unit = ScaleUnit.getScaleUnit(size);
@@ -157,12 +160,13 @@ public abstract class AbstractMavenTransferListener extends AbstractTransferList
}
public String formatProgress(long progressedSize, long size) {
- Validate.isTrue(progressedSize >= 0L, "progressed file size cannot be negative: %s", progressedSize);
- Validate.isTrue(
- size < 0L || progressedSize <= size,
- "progressed file size cannot be greater than size: %s > %s",
- progressedSize,
- size);
+ if (progressedSize < 0L) {
+ throw new IllegalArgumentException("progressed file size cannot be negative: " + size);
+ }
+ if (size >= 0 && progressedSize > size) {
+ throw new IllegalArgumentException(
+ "progressed file size cannot be greater than size: " + progressedSize + " > " + size);
+ }
if (size >= 0L && progressedSize != size) {
ScaleUnit unit = ScaleUnit.getScaleUnit(size);
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java
index 2cbd5e6014..d3c943f7e4 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java
@@ -25,7 +25,6 @@ import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.eclipse.aether.transfer.TransferCancelledException;
import org.eclipse.aether.transfer.TransferEvent;
import org.eclipse.aether.transfer.TransferResource;
@@ -96,7 +95,8 @@ public class ConsoleMavenTransferListener extends AbstractMavenTransferListener
StringBuilder status = new StringBuilder();
if (printResourceNames) {
- status.append(StringUtils.substringAfterLast(resourceName, "/"));
+ int idx = resourceName.lastIndexOf('/');
+ status.append(idx < 0 ? resourceName : resourceName.substring(idx + 1));
status.append(" (");
}
diff --git a/pom.xml b/pom.xml
index 04039d9098..836600abb5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -407,11 +407,6 @@ under the License.
commons-jxpath
${jxpathVersion}
-
- org.apache.commons
- commons-lang3
- ${commonsLangVersion}
-
org.codehaus.plexus
plexus-sec-dispatcher