Skip to content

Commit

Permalink
hide maven transfer progress via flag instead of regexp filtering.
Browse files Browse the repository at this point in the history
 - sets --no-transfer-progress as default global maven option
 - removes console regexp filter which fixes apache#4017
 - regexp filter didn't work with current maven anyway
  • Loading branch information
mbien committed Nov 9, 2022
1 parent 47632f8 commit 946c688
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public class CommandLineOutputHandler extends AbstractOutputHandler {
private static final RequestProcessor PROCESSOR = new RequestProcessor("Maven ComandLine Output Redirection", Integer.getInteger("maven.concurrent.builds", 16) * 2); //NOI18N
private static final Logger LOG = Logger.getLogger(CommandLineOutputHandler.class.getName());
private InputOutput inputOutput;
/*test*/ static final Pattern DOWNLOAD = Pattern.compile("^(\\d+(/\\d*)? ?(M|K|b|KB|B|\\?)\\s*)+$"); //NOI18N
private static final Pattern linePattern = Pattern.compile("\\[(DEBUG|INFO|WARNING|ERROR|FATAL)\\] (.*)"); // NOI18N
public static final Pattern startPatternM2 = Pattern.compile("\\[INFO\\] \\[([\\w]*):([\\w]*)[ ]?.*\\]"); // NOI18N
public static final Pattern startPatternM3 = Pattern.compile("\\[INFO\\] --- (\\S+):\\S+:(\\S+)(?: [(]\\S+[)])? @ \\S+ ---"); // ExecutionEventLogger.mojoStarted NOI18N
Expand Down Expand Up @@ -314,31 +313,22 @@ private String readLine() throws IOException {
checkSleepiness();
}

boolean isDownloadProgress = false;
if(line.length() > 0 && line.charAt(line.length() - 1) == '\r') {
// issue #252514
if (DOWNLOAD.matcher(line).matches()) {
isDownloadProgress = true;
} else {
line = line.substring(0, line.length() - 1);
}
line = line.substring(0, line.length() - 1);
}
if(!isDownloadProgress) {
Matcher match = linePattern.matcher(line);
if (match.matches()) {
String levelS = match.group(1);
Level level = Level.valueOf(levelS);
String text = match.group(2);
updateFoldForException(text);
processLine(MavenSettings.getDefault().isShowLoggingLevel() ? line : text, stdOut, level);
if (level == Level.INFO && contextImpl == null) { //only perform for maven 2.x now
checkProgress(text);
}
} else {
// oh well..
updateFoldForException(line);
processLine(line, stdOut, Level.INFO);
Matcher lineMatcher = linePattern.matcher(line);
if (lineMatcher.matches()) {
Level level = Level.valueOf(lineMatcher.group(1));
String text = lineMatcher.group(2);
updateFoldForException(text);
processLine(MavenSettings.getDefault().isShowLoggingLevel() ? line : text, stdOut, level);
if (level == Level.INFO && contextImpl == null) { //only perform for maven 2.x now
checkProgress(text);
}
} else {
// oh well..
updateFoldForException(line);
processLine(line, stdOut, Level.INFO);
}
if (contextImpl == null && firstFailure == null) {
Matcher match = reactorFailure.matcher(line);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ FORCE_UPTODATE_CHECK=Force upToDate check for any relevant registered plugins.\n
SUPPRESS_UPTODATE_CHECK=Suppress upToDate check for any relevant registered plugins.\n\nExclusive with --check-plugin-updates.
FORCES_A_CHECK=Forces a check for updated releases and snapshots on remote repositories.
DON'T_USE_PLUGIN-REGISTRY=Don't use ~/.m2/plugin-registry.xml for plugin versions
NO_TRANSFER_PROGRESS=Don't print the download progress.
TIT_Add_Globals=Add Global Option(s)
SettingsPanel.jLabel1.text=Dependency Download Strategy :
TIT_NEVER=Never
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private MavenSettings() {
//import from older versions
String defOpts = getPreferences().get(PROP_DEFAULT_OPTIONS, null);
if (defOpts == null) {
defOpts = "";
defOpts = getDefaultOptions();
//only when not already set by user or by previous import
String debug = getPreferences().get(PROP_DEBUG, null);
if (debug != null) {
Expand Down Expand Up @@ -223,7 +223,7 @@ private MavenSettings() {
}

public String getDefaultOptions() {
return getPreferences().get(PROP_DEFAULT_OPTIONS, ""); //NOI18N
return getPreferences().get(PROP_DEFAULT_OPTIONS, "--no-transfer-progress"); //NOI18N
}

public void setDefaultOptions(String options) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ public Component getListCellRendererComponent(JList list, Object value, int inde
"--check-plugin-updates", //NOI18N
"--no-plugin-updates", //NOI18N
"--update-snapshots", //NOI18N
"--no-plugin-registry" //NOI18N
"--no-plugin-registry", //NOI18N
"--no-transfer-progress" //NOI18N
};


Expand All @@ -263,7 +264,8 @@ static String[] getAvailableOptionsDescriptions() {
org.openide.util.NbBundle.getMessage(SettingsPanel.class, "FORCE_UPTODATE_CHECK"),
org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SUPPRESS_UPTODATE_CHECK"),
org.openide.util.NbBundle.getMessage(SettingsPanel.class, "FORCES_A_CHECK"),
org.openide.util.NbBundle.getMessage(SettingsPanel.class, "DON'T_USE_PLUGIN-REGISTRY")
org.openide.util.NbBundle.getMessage(SettingsPanel.class, "DON'T_USE_PLUGIN-REGISTRY"),
org.openide.util.NbBundle.getMessage(SettingsPanel.class, "NO_TRANSFER_PROGRESS")
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package org.netbeans.modules.maven.execute;

import java.util.regex.Matcher;
import static junit.framework.TestCase.fail;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
Expand All @@ -42,23 +41,6 @@ public static void setUpClass() throws Exception {
@AfterClass
public static void tearDownClass() throws Exception {
}

@Test
public void testDownloadPattern() {
String[] lines = {
"51521/?", "11/12K", "11/12M", "51521/120000b",
"51521/? 12/25K", "34/263M 464/500b",
"51521/? 13/25K 4034/4640M",
// #189465: M3 ConsoleMavenTransferListener.doProgress
"59/101 KB ", "1/3 B ", "55 KB", "300 B ",
"10/101 KB 48/309 KB ", // sometimes seems to jam
};
for (String line : lines) {
if (!CommandLineOutputHandler.DOWNLOAD.matcher(line).matches()) {
fail("Line " + line + " not skipped");
}
}
}

@Test
public void testRegExp() throws Exception {
Expand Down

0 comments on commit 946c688

Please sign in to comment.