mirror of https://github.com/apache/maven.git
[MNG-6825] Get rid of commons-lang
This commit is contained in:
parent
26056b9b20
commit
b2ee29e03e
|
@ -30,13 +30,6 @@ under the License.
|
|||
|
||||
<name>Maven Artifact</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
|
|
@ -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<String, Artifact> artifactMapByVersionlessId(Collection<Artifact> artifacts) {
|
||||
|
|
|
@ -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")) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -123,10 +123,6 @@ under the License.
|
|||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>failureaccess</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.inject</groupId>
|
||||
<artifactId>javax.inject</artifactId>
|
||||
|
@ -140,10 +136,6 @@ under the License.
|
|||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-classworlds</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
|
@ -158,6 +150,11 @@ under the License.
|
|||
<artifactId>commons-jxpath</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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<String> lines = FileUtils.readLines(apt);
|
||||
List<String> lines = Files.readAllLines(apt.toPath());
|
||||
|
||||
for (String line : lines) {
|
||||
if (line.startsWith("||")) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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(
|
||||
"<packaging>pom</packaging>",
|
||||
"<packaging>pom</packaging><properties><addedProperty>addedValue</addedProperty></properties>");
|
||||
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"));
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -146,10 +146,6 @@ under the License.
|
|||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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(" (");
|
||||
}
|
||||
|
||||
|
|
5
pom.xml
5
pom.xml
|
@ -407,11 +407,6 @@ under the License.
|
|||
<artifactId>commons-jxpath</artifactId>
|
||||
<version>${jxpathVersion}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commonsLangVersion}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-sec-dispatcher</artifactId>
|
||||
|
|
Loading…
Reference in New Issue