Skip to content

Commit

Permalink
Remove redundant
Browse files Browse the repository at this point in the history
raw-streams option is handled now in maven, also remove
some unused methods.
  • Loading branch information
cstamas committed Nov 13, 2024
1 parent 2bd53ee commit 6602046
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.maven.cling.invoker.mvn.CommonsCliMavenOptions;
import org.apache.maven.jline.MessageUtils;
Expand All @@ -55,18 +54,14 @@ protected CommonsCliDaemonMavenOptions(String source, CLIManager cliManager, Com
super(source, cliManager, commandLine);
}

public org.apache.commons.cli.Options getOptions() {
return this.cliManager.getOptions();
}

private static CommonsCliDaemonMavenOptions interpolate(
CommonsCliDaemonMavenOptions options, Collection<Map<String, String>> properties) {
@Override
public DaemonMavenOptions interpolate(Collection<Map<String, String>> properties) {
try {
// now that we have properties, interpolate all arguments
BasicInterpolator interpolator = createInterpolator(properties);
CommandLine.Builder commandLineBuilder = new CommandLine.Builder();
commandLineBuilder.setDeprecatedHandler(o -> {});
for (Option option : options.commandLine.getOptions()) {
for (Option option : commandLine.getOptions()) {
if (!CLIManager.USER_PROPERTY.equals(option.getOpt())) {
List<String> values = option.getValuesList();
for (ListIterator<String> it = values.listIterator(); it.hasNext(); ) {
Expand All @@ -75,24 +70,16 @@ private static CommonsCliDaemonMavenOptions interpolate(
}
commandLineBuilder.addOption(option);
}
for (String arg : options.commandLine.getArgList()) {
for (String arg : commandLine.getArgList()) {
commandLineBuilder.addArg(interpolator.interpolate(arg));
}
return new CommonsCliDaemonMavenOptions(
options.source, (CLIManager) options.cliManager, commandLineBuilder.build());
return new CommonsCliDaemonMavenOptions(source, (CLIManager) cliManager, commandLineBuilder.build());
} catch (InterpolationException e) {
throw new IllegalArgumentException("Could not interpolate CommonsCliOptions", e);
}
}

@Override
public DaemonMavenOptions interpolate(Collection<Map<String, String>> properties) {
return interpolate(this, properties);
}

protected static class CLIManager extends CommonsCliMavenOptions.CLIManager {
public static final String RAW_STREAMS = "ras";

private static final Pattern HTML_TAGS_PATTERN = Pattern.compile("<[^>]*>");
private static final Pattern COLUMNS_DETECTOR_PATTERN = Pattern.compile("^[ ]+[^s]");
private static final Pattern WS_PATTERN = Pattern.compile("\\s+");
Expand All @@ -101,15 +88,6 @@ static String toPlainText(String javadocText) {
return HTML_TAGS_PATTERN.matcher(javadocText).replaceAll("");
}

@Override
protected void prepareOptions(Options options) {
super.prepareOptions(options);
options.addOption(Option.builder(RAW_STREAMS)
.longOpt("raw-streams")
.desc("Use raw-streams for daemon communication")
.build());
}

@Override
public void displayHelp(String command, Consumer<String> pw) {
List<String> mvnHelp = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

import org.apache.maven.cling.invoker.mvn.LayeredMavenOptions;

Expand All @@ -43,11 +42,6 @@ private LayeredDaemonMavenOptions(List<DaemonMavenOptions> options) {
super(options);
}

@Override
public Optional<Boolean> rawStreams() {
return returnFirstPresentOrEmpty(DaemonMavenOptions::rawStreams);
}

@Override
public DaemonMavenOptions interpolate(Collection<Map<String, String>> properties) {
ArrayList<DaemonMavenOptions> interpolatedOptions = new ArrayList<>(options.size());
Expand Down

0 comments on commit 6602046

Please sign in to comment.