Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@

import org.apache.maven.cli.internal.extension.model.CoreExtension;
import org.apache.maven.cli.internal.extension.model.io.xpp3.CoreExtensionsXpp3Reader;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.mvndaemon.mvnd.common.Environment;
import org.mvndaemon.mvnd.common.InterpolationHelper;
Expand Down Expand Up @@ -440,8 +439,8 @@ private String defaultValue(Environment env) {
private static List<String> parseExtClasspath(Path userDir) {
String extClassPath = System.getProperty(EXT_CLASS_PATH);
List<String> jars = new ArrayList<>();
if (StringUtils.isNotEmpty(extClassPath)) {
for (String jar : StringUtils.split(extClassPath, File.pathSeparator)) {
if (extClassPath != null) {
for (String jar : extClassPath.split(File.pathSeparator)) {
Path path = userDir.resolve(jar).toAbsolutePath();
jars.add(path.toString());
}
Expand Down
21 changes: 5 additions & 16 deletions daemon-m39/src/main/java/org/apache/maven/cli/DaemonMavenCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
import org.codehaus.plexus.classworlds.ClassWorld;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.aether.transfer.TransferListener;
import org.mvndaemon.mvnd.cache.invalidating.InvalidatingExtensionRealmCache;
import org.mvndaemon.mvnd.cache.invalidating.InvalidatingPluginArtifactsCache;
Expand Down Expand Up @@ -652,12 +651,10 @@ private List<File> parseExtClasspath(CliRequest cliRequest) {

List<File> jars = new ArrayList<>();

if (StringUtils.isNotEmpty(extClassPath)) {
for (String jar : StringUtils.split(extClassPath, File.pathSeparator)) {
if (extClassPath != null) {
for (String jar : extClassPath.split(File.pathSeparator)) {
File file = resolveFile(new File(jar), cliRequest.workingDirectory);

slf4jLogger.debug(" Included {}", file);

jars.add(file);
}
}
Expand Down Expand Up @@ -819,19 +816,11 @@ private String getResumeFromSelector(List<MavenProject> mavenProjects, MavenProj

private void logSummary(
ExceptionSummary summary, Map<String, String> references, String indent, boolean showErrors) {
String referenceKey = "";

if (StringUtils.isNotEmpty(summary.getReference())) {
referenceKey = references.get(summary.getReference());
if (referenceKey == null) {
referenceKey = "[Help " + (references.size() + 1) + "]";
references.put(summary.getReference(), referenceKey);
}
}

String msg = summary.getMessage();

if (StringUtils.isNotEmpty(referenceKey)) {
if (!summary.getReference().isEmpty()) {
String referenceKey =
references.computeIfAbsent(summary.getReference(), k -> "[Help " + (references.size() + 1) + "]");
if (msg.indexOf('\n') < 0) {
msg += " -> " + buffer().strong(referenceKey);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import java.util.Properties;
import java.util.stream.Stream;

import org.apache.commons.lang3.StringUtils;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.project.MavenProject;
import org.slf4j.Logger;
Expand Down Expand Up @@ -144,10 +143,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())) {
if (properties.containsKey(REMAINING_PROJECTS)
&& (request.getResumeFrom() == null || request.getResumeFrom().isEmpty())) {
String propertyValue = properties.getProperty(REMAINING_PROJECTS);
Stream.of(propertyValue.split(PROPERTY_DELIMITER))
.filter(StringUtils::isNotEmpty)
.filter(s -> s != null && !s.isEmpty())
.forEach(request.getSelectedProjects()::add);
LOGGER.info("Resuming from {} due to the --resume / -r feature.", propertyValue);
}
Expand Down
52 changes: 17 additions & 35 deletions daemon-m40/src/main/java/org/apache/maven/cli/DaemonMavenCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.ParseException;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.maven.InternalErrorException;
import org.apache.maven.Maven;
import org.apache.maven.building.FileSource;
Expand Down Expand Up @@ -88,7 +87,6 @@
import org.codehaus.plexus.classworlds.ClassWorld;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.aether.transfer.TransferListener;
import org.mvndaemon.mvnd.cache.invalidating.InvalidatingExtensionRealmCache;
import org.mvndaemon.mvnd.cache.invalidating.InvalidatingPluginArtifactsCache;
Expand Down Expand Up @@ -637,12 +635,10 @@ private List<File> parseExtClasspath(CliRequest cliRequest) {

List<File> jars = new ArrayList<>();

if (StringUtils.isNotEmpty(extClassPath)) {
for (String jar : StringUtils.split(extClassPath, File.pathSeparator)) {
if (extClassPath != null) {
for (String jar : extClassPath.split(File.pathSeparator)) {
File file = resolveFile(new File(jar), cliRequest.workingDirectory);

slf4jLogger.debug(" Included {}", file);

jars.add(file);
}
}
Expand Down Expand Up @@ -787,19 +783,11 @@ private String getResumeFromSelector(List<MavenProject> mavenProjects, MavenProj

private void logSummary(
ExceptionSummary summary, Map<String, String> references, String indent, boolean showErrors) {
String referenceKey = "";

if (StringUtils.isNotEmpty(summary.getReference())) {
referenceKey = references.get(summary.getReference());
if (referenceKey == null) {
referenceKey = "[Help " + (references.size() + 1) + "]";
references.put(summary.getReference(), referenceKey);
}
}

String msg = summary.getMessage();

if (StringUtils.isNotEmpty(referenceKey)) {
if (!summary.getReference().isEmpty()) {
String referenceKey =
references.computeIfAbsent(summary.getReference(), k -> "[Help " + (references.size() + 1) + "]");
if (msg.indexOf('\n') < 0) {
msg += " -> " + buffer().strong(referenceKey);
} else {
Expand Down Expand Up @@ -1241,29 +1229,23 @@ 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.");
}
try {
String str = threadConfiguration.substring(0, threadConfiguration.length() - 1);
float coreMultiplier = Float.parseFloat(str);

float coreMultiplier = Float.parseFloat(threadConfiguration);
if (coreMultiplier <= 0.0f) {
throw new IllegalArgumentException("Invalid threads core multiplier value: '" + threadConfiguration
+ "C'. Value must be positive.");
}

if (coreMultiplier <= 0.0f) {
int procs = Runtime.getRuntime().availableProcessors();
int threads = (int) (coreMultiplier * procs);
return threads == 0 ? 1 : threads;
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Invalid threads core multiplier value: '" + threadConfiguration
+ "C'. Value must be positive.");
+ "C'. Supported are int and float values ending with C.");
}

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.");
}

try {
int threads = Integer.parseInt(threadConfiguration);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.codehaus.plexus.components.interactivity.OutputHandler;
import org.codehaus.plexus.components.interactivity.Prompter;
import org.codehaus.plexus.components.interactivity.PrompterException;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.sisu.Priority;
import org.eclipse.sisu.Typed;
import org.mvndaemon.mvnd.common.Message;
Expand Down Expand Up @@ -115,7 +114,7 @@ String doPrompt(String message, List<Object> possibleValues, String defaultReply
} catch (IOException e) {
throw new PrompterException("Failed to prompt user", e);
}
if (StringUtils.isEmpty(line)) {
if (line == null || line.isEmpty()) {
line = defaultReply;
}
if (line != null && (possibleValues != null && !possibleValues.contains(line))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.apache.maven.execution.ExecutionEvent;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecution;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.sisu.Typed;
import org.mvndaemon.mvnd.common.Environment;
import org.slf4j.Logger;
Expand Down Expand Up @@ -192,9 +191,17 @@ private static class Mojo {

public String name() {
String name = mojo.getKey();
String truncatedName =
name.length() >= MAX_NAME_LENGTH ? StringUtils.substring(name, 0, MAX_NAME_LENGTH) : name + " ";
return StringUtils.rightPad(truncatedName, MAX_NAME_LENGTH, ".");
if (name.length() < MAX_NAME_LENGTH) {
StringBuilder sb = new StringBuilder(MAX_NAME_LENGTH);
sb.append(name);
sb.append(' ');
while (sb.length() < MAX_NAME_LENGTH) {
sb.append('.');
}
return sb.toString();
} else {
return name.substring(0, MAX_NAME_LENGTH);
}
}

public long duration() {
Expand Down