Skip to content
Open
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
11 changes: 11 additions & 0 deletions dist/common/src/main/licenses/licenses.xml
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,17 @@
</license>
</licenses>
</dependency>
<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
<licenses>
<license>
<name>Apache License 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
<distribution>repo</distribution>
</license>
</licenses>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>staxmapper</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<artifact name="${org.apache.maven.resolver:maven-resolver-transport-file}"/>
<artifact name="${org.apache.maven.resolver:maven-resolver-transport-http}"/>
<artifact name="${org.apache.maven.resolver:maven-resolver-util}"/>
<artifact name="${org.fusesource.jansi:jansi}"/>
</resources>

<dependencies>
Expand Down
5 changes: 5 additions & 0 deletions dist/standalone-galleon-pack/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@
</exclusions>
</dependency>

<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
</dependency>

<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions dist/wildfly-galleon-pack/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@
</exclusions>
</dependency>

<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
</dependency>

<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
Expand Down
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<version.org.jboss.galleon>6.0.4.Final</version.org.jboss.galleon>
<version.org.eclipse.jgit>6.10.0.202406032230-r</version.org.eclipse.jgit>
<version.com.fasterxml.jackson>2.18.2</version.com.fasterxml.jackson>
<version.org.fusesource.jansi>2.4.2</version.org.fusesource.jansi>
<version.org.jboss.logmanager>2.1.19.Final</version.org.jboss.logmanager>
<version.org.jboss.logging.slf4j-jboss-logmanager>2.0.1.Final</version.org.jboss.logging.slf4j-jboss-logmanager>
<version.org.jboss.logging.jboss-logging-processor>2.2.1.Final</version.org.jboss.logging.jboss-logging-processor>
Expand Down Expand Up @@ -260,6 +261,12 @@
<version>${version.org.codehaus.plexus-utils}</version>
</dependency>

<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
<version>${version.org.fusesource.jansi}</version>
</dependency>

<dependency>
<groupId>org.jboss</groupId>
<artifactId>staxmapper</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions prospero-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
<groupId>com.networknt</groupId>
<artifactId>json-schema-validator</artifactId>
</dependency>
<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
</dependency>

<dependency>
<groupId>org.wildfly.prospero</groupId>
<artifactId>prospero-common</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
import java.util.Optional;
import java.util.Scanner;

import org.apache.commons.lang3.StringUtils;
import org.fusesource.jansi.AnsiConsole;
import org.wildfly.prospero.api.Console;
import org.wildfly.prospero.api.ProvisioningProgressEvent;
import org.wildfly.prospero.api.ArtifactChange;
import picocli.CommandLine;

import static org.fusesource.jansi.Ansi.ansi;
import static org.jboss.galleon.Constants.TRACK_CONFIGS;
import static org.jboss.galleon.Constants.TRACK_LAYOUT_BUILD;
import static org.jboss.galleon.Constants.TRACK_PACKAGES;
Expand All @@ -39,21 +40,16 @@
import static org.wildfly.prospero.galleon.GalleonEnvironment.TRACK_RESOLVING_VERSIONS;

@SuppressWarnings("PMD.TooManyStaticImports")
public class CliConsole implements Console {
public class CliConsole implements Console,AutoCloseable {

private static final int MAX_LENGTH = 120;
private static final int MAX_LENGTH = AnsiConsole.getTerminalWidth() == 0 ? 120 : AnsiConsole.getTerminalWidth();
protected static final String DOTS_SEPARATOR = "...";

private static class ProgressLogger {
private final String starting;
private final String completed;
private final String progress;

ProgressLogger(String starting, String completed, String progress) {
this.starting = starting;
this.completed = completed;
this.progress = progress;
}

ProgressLogger(String starting, String completed) {
this.starting = starting;
this.completed = completed;
Expand All @@ -71,27 +67,28 @@ String progress() {
}
}

private class Cli {
int lastLength;
private class Cli implements AutoCloseable {
PrintStream out;

Cli(PrintStream out) {
AnsiConsole.systemInstall();
this.out = out;
}

synchronized void print(String msg) {
final String eraser = StringUtils.repeat(' ', this.lastLength);
out.print("\r" + eraser + "\r");
lastLength = msg.length();
synchronized void print(String msg) {
out.print(ansi().cursorToColumn(0).eraseLine());
out.print(msg);
}

synchronized void println(String msg) {
final String eraser = StringUtils.repeat(' ', this.lastLength);
out.print("\r" + eraser + "\r");
lastLength = msg.length();
out.print(ansi().cursorToColumn(0).eraseLine());
out.println(msg);
}

@Override
public void close() {
AnsiConsole.systemUninstall();
}
}

private static HashMap<String, ProgressLogger> loggers = new HashMap<>();
Expand Down Expand Up @@ -120,27 +117,26 @@ public void progressUpdate(ProvisioningProgressEvent update) {

final String item;
if (update.isSlowPhase()) {
item = " " + CliMessages.MESSAGES.installProgressWait() + "...";
item = " " + CliMessages.MESSAGES.installProgressWait() + DOTS_SEPARATOR;
} else {
item = update.getCurrentItem();
}

final String progressMsg;
final String details = item == null ? "" : item;

if (update.getTotal() > 0) {
progressMsg = String.format(" %d/%d(%.0f%%) ", update.getCompleted(), update.getTotal(), update.getProgress());
} else {
progressMsg = "";
}

final String text;
if (logger.progress.length() + progressMsg.length() > MAX_LENGTH) {
final String details = item == null ? "" : item;
int textLength = logger.progress.length() + progressMsg.length();
if (textLength > MAX_LENGTH) {
text = (logger.progress() + progressMsg).substring(0, MAX_LENGTH);
} else if (logger.progress.length() + progressMsg.length() + details.length() > MAX_LENGTH) {
int used = logger.progress.length() + progressMsg.length();
int left = MAX_LENGTH - used;
text = logger.progress() + progressMsg + "..." + details.substring(details.length() - left);
} else if (textLength + details.length() > MAX_LENGTH) {
int left = MAX_LENGTH - textLength - DOTS_SEPARATOR.length();
text = logger.progress() + progressMsg + DOTS_SEPARATOR + details.substring(details.length() - left);
} else {
text = logger.progress() + progressMsg + details;
}
Expand Down Expand Up @@ -262,4 +258,8 @@ public void printf(String text, String... args) {
}
}

@Override
public void close() {
cli.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,10 @@ private static void enableDebugLogging() {
}

static int execute(String[] args) {
CliConsole console = new CliConsole();
CommandLine commandLine = createCommandLine(console, args);
return commandLine.execute(args);
try (CliConsole console = new CliConsole()) {
CommandLine commandLine = createCommandLine(console, args);
return commandLine.execute(args);
}
}

static void logException(Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.wildfly.prospero.api.Console;
import org.wildfly.prospero.api.ProvisioningProgressEvent;

import java.io.File;
import java.util.HashSet;

import static org.wildfly.prospero.galleon.GalleonEnvironment.TRACK_JB_ARTIFACTS_RESOLVE;
Expand Down Expand Up @@ -97,7 +96,8 @@ public void transferSucceeded(TransferEvent event) {
ProsperoLogger.ROOT_LOGGER.debug("Downloaded artifact: " + item);
}

final int fileNameIndex = item.lastIndexOf(File.separator);
// note the fileName has Unix separators regardless of the actual OS
final int fileNameIndex = item.lastIndexOf("/");
item = item.substring(fileNameIndex + 1);
if (console != null) {
if ("maven-metadata.xml".equals(item)) {
Expand Down