Skip to content
Open
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 @@ -25,6 +25,7 @@
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -39,6 +40,16 @@ public enum Types_Of_Data {

private static final Logger LOGGER = LoggerFactory.getLogger(ProcessData.class);

// Patterns to filter out download-related messages from error stream
private static final Pattern[] DOWNLOAD_PATTERNS = {
Pattern.compile(".*\\[INFO\\]\\s+(Downloading|Downloaded):.*"), // Maven download messages
Pattern.compile(".*Downloading\\s+.*"), // Generic downloading messages
Pattern.compile(".*Downloaded\\s+.*"), // Generic downloaded messages
Pattern.compile(".*progress:\\s*\\d+%.*", Pattern.CASE_INSENSITIVE), // Progress indicators
Pattern.compile(".*\\d+/\\d+\\s*(KB|MB|GB|bytes).*"), // Size progress (e.g., 1024/2048 KB)
Pattern.compile(".*\\d+\\.\\d+\\s*(KB|MB|GB)\\s+(downloaded|transferred).*", Pattern.CASE_INSENSITIVE) // Size with downloaded/transferred
};

private Process checked_process;
private boolean printToConsole = false;

Expand Down Expand Up @@ -149,6 +160,27 @@ public String getErrorStream() {
return this.errorStream;
}

/**
* Filters out download-related messages from error stream output.
* This method checks if the given message matches common download patterns
* (Maven downloads, progress indicators, size information, etc.)
*
* @param message The message to check
* @return true if the message should be filtered out (is a download message), false otherwise
*/
private boolean isDownloadMessage(String message) {
if (message == null || message.trim().isEmpty()) {
return false;
}

for (Pattern pattern : DOWNLOAD_PATTERNS) {
if (pattern.matcher(message).matches()) {
return true;
}
}
return false;
}

@Override
public String toString() {
StringBuilder result = new StringBuilder();
Expand Down Expand Up @@ -208,9 +240,8 @@ private void buildOutputAndErrorStreamData() throws IOException {
outputProduced = true;
String temp = new String(tempSB);
temp = temp.replaceAll("Pseudo-terminal will not be allocated because stdin is not a terminal.", "");
//TODO : error stream output need to be improved, because it outputs downloading information.
if (printToConsole) {
if (!temp.trim().equals("")) {
if (!temp.trim().equals("") && !isDownloadMessage(temp)) {
if (temp.toLowerCase().contains("error") || temp.toLowerCase().contains("failed")) {
LOGGER.warn(temp.trim());
} else {
Expand Down
Loading