diff --git a/maven-artifact/pom.xml b/maven-artifact/pom.xml
index 3059992da681..a7459b843282 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 2b44cf3f747a..8ea6710a56cb 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.Map;
import java.util.regex.Matcher;
-import org.apache.commons.lang3.Validate;
import org.apache.maven.artifact.versioning.VersionRange;
/**
@@ -89,10 +88,15 @@ public static String key(String groupId, String artifactId, String version) {
}
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 10da535c1530..ceaab0a77e90 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 @@
import java.util.StringTokenizer;
-import static org.apache.commons.lang3.math.NumberUtils.isDigits;
-
/**
* Default implementation of artifact versioning.
*
@@ -168,6 +166,19 @@ public final void parseVersion(String version) {
}
}
+ 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 48eea0ac5343..1ad0d487eedd 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 MetadataBridge(ArtifactMetadata metadata) {
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 29bf7494f29f..d34af30fdd44 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 @@
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 void testArtifactInstallation() throws Exception {
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 abc40b549130..3c6f5bc35aab 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 5e5291c1ff2e..b1deeb00ecac 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 DefaultBeanConfigurationRequest setConfiguration(
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 DefaultBeanConfigurationRequest setConfiguration(
}
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 a5187836400d..8a4ded84fbcb 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.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 @@ private Properties loadResumptionFile(Path rootBuildDirectory) {
// 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 1df33dd898a3..3b2a1658476c 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 @@
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 ArtifactCoordinate create(@Nonnull ArtifactCoordinateFactoryRequest reque
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 f03a9cebbec0..2788b77284d6 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 @@
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 Artifact create(@Nonnull ArtifactFactoryRequest request) {
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 64406fe48cc7..a100c349a0f8 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 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 MavenPluginJavaPrerequisiteChecker(final VersionScheme versionScheme) {
@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 f00cb4b2b7de..4a349330ea22 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 @@
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 void storeInLocalRepository(ArtifactRepository localRepository, ArtifactR
// ----------------------------------------------------------------------------
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 ac5d18d7c38d..9211c615ff71 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 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 @@ private String loadMavenVersion() {
@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 boolean isMavenVersion(String versionRange) {
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 bc062ee8822a..f4251847464d 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 @@
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 3f3d1e08a790..3201e752d1a5 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 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 @@ private void resolve(Artifact artifact, ArtifactResolutionRequest request) throw
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 7d34788d716e..e431b5cc3f56 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 void testReadModifiedPoms(@TempDir Path tempDir) throws Exception {
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 6f9d9639046e..9b8214121c84 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.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 void get(
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 void get(
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 5d8bcf98878b..957d2d79a4db 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 d3f5695d4db1..bc879c640913 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.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 @@ static String createMavenVersionString(Properties buildProperties) {
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/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
index 047f675fd40f..d5fd812158cd 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
@@ -48,7 +48,6 @@
import org.apache.commons.cli.Option;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.UnrecognizedOptionException;
-import org.apache.commons.lang3.math.NumberUtils;
import org.apache.maven.BuildAbort;
import org.apache.maven.InternalErrorException;
import org.apache.maven.Maven;
@@ -1422,43 +1421,30 @@ private void enableOnAbsentOption(
}
int calculateDegreeOfConcurrency(String threadConfiguration) {
- if (threadConfiguration.endsWith("C")) {
- threadConfiguration = threadConfiguration.substring(0, threadConfiguration.length() - 1);
-
- if (!NumberUtils.isParsable(threadConfiguration)) {
- throw new IllegalArgumentException("Invalid threads core multiplier value: '" + threadConfiguration
- + "C'. Supported are int and float values ending with C.");
- }
-
- float coreMultiplier = Float.parseFloat(threadConfiguration);
-
- if (coreMultiplier <= 0.0f) {
- throw new IllegalArgumentException("Invalid threads core multiplier value: '" + threadConfiguration
- + "C'. Value must be positive.");
- }
+ try {
+ if (threadConfiguration.endsWith("C")) {
+ String str = threadConfiguration.substring(0, threadConfiguration.length() - 1);
+ float coreMultiplier = Float.parseFloat(str);
- int procs = Runtime.getRuntime().availableProcessors();
- int threads = (int) (coreMultiplier * procs);
- return threads == 0 ? 1 : threads;
- } else {
- if (!NumberUtils.isParsable(threadConfiguration)) {
- throw new IllegalArgumentException(
- "Invalid threads value: '" + threadConfiguration + "'. Supported are int values.");
- }
+ if (coreMultiplier <= 0.0f) {
+ throw new IllegalArgumentException("Invalid threads core multiplier value: '" + threadConfiguration
+ + "'. Value must be positive.");
+ }
- try {
+ int procs = Runtime.getRuntime().availableProcessors();
+ int threads = (int) (coreMultiplier * procs);
+ return threads == 0 ? 1 : threads;
+ } else {
int threads = Integer.parseInt(threadConfiguration);
-
if (threads <= 0) {
throw new IllegalArgumentException(
"Invalid threads value: '" + threadConfiguration + "'. Value must be positive.");
}
-
return threads;
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException(
- "Invalid threads value: '" + threadConfiguration + "'. Supported are integer values.");
}
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException("Invalid threads value: '" + threadConfiguration
+ + "'. Supported are int and float values ending with C.");
}
}
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 514538bed117..f1e84d8c8e8f 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.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 String symbol() {
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 String format(long size, ScaleUnit unit) {
@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 String format(long size, ScaleUnit unit, boolean omitSymbol) {
}
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 2cbd5e6014cd..d3c943f7e4d8 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.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 @@ private String getStatus(String resourceName, long complete, long total) {
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/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java b/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java
index 54e937b31d1a..3dba909e6718 100644
--- a/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java
+++ b/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java
@@ -158,7 +158,6 @@ public void testCalculateDegreeOfConcurrency() {
int cpus = Runtime.getRuntime().availableProcessors();
assertEquals((int) (cpus * 2.2), cli.calculateDegreeOfConcurrency("2.2C"));
assertEquals(1, cli.calculateDegreeOfConcurrency("0.0001C"));
- assertThrows(IllegalArgumentException.class, () -> cli.calculateDegreeOfConcurrency("2.C"));
assertThrows(IllegalArgumentException.class, () -> cli.calculateDegreeOfConcurrency("-2.2C"));
assertThrows(IllegalArgumentException.class, () -> cli.calculateDegreeOfConcurrency("0C"));
}
diff --git a/pom.xml b/pom.xml
index 04039d90989a..836600abb571 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