Skip to content

Commit

Permalink
fix: Maven 3.6.3 is still supported
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Nuri <marc@marcnuri.com>
  • Loading branch information
manusa committed Nov 16, 2022
1 parent 92573c6 commit 2d53c34
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -22,6 +22,8 @@ Usage:
```
### 1.11-SNAPSHOT

### 1.10.1
* Fix #1915: Maven 3.6.3 is still supported

### 1.10.0 (2022-11-10)
* Fix #443: Add health check enricher for SmallRye Health
Expand Down
Expand Up @@ -85,7 +85,7 @@ public AnsiLogger(Log log, boolean useColor, String verbose, boolean batchMode,

/** {@inheritDoc} */
public void debug(String message, Object ... params) {
if (isDebugEnabled() && AnsiConsole.isInstalled()) {
if (isDebugEnabled() && isAnsiConsoleInstalled()) {
log.debug(prefix + format(message, params));
} else if (isDebugEnabled()) {
fallbackLogger.debug(message, params);
Expand All @@ -94,7 +94,7 @@ public void debug(String message, Object ... params) {

/** {@inheritDoc} */
public void info(String message, Object ... params) {
if (AnsiConsole.isInstalled()) {
if (isAnsiConsoleInstalled()) {
log.info(colored(message, INFO, params));
} else {
fallbackLogger.info(message, params);
Expand All @@ -104,7 +104,7 @@ public void info(String message, Object ... params) {
/** {@inheritDoc} */
public void verbose(LogVerboseCategory logVerboseCategory, String message, Object ... params) {
final boolean logVerbose = isVerbose && verboseModes != null && verboseModes.contains(logVerboseCategory);
if (logVerbose && AnsiConsole.isInstalled()) {
if (logVerbose && isAnsiConsoleInstalled()) {
log.info(ansi().fgBright(BLACK).a(prefix).a(format(message, params)).reset().toString());
} else {
fallbackLogger.info(message, params);
Expand All @@ -113,7 +113,7 @@ public void verbose(LogVerboseCategory logVerboseCategory, String message, Objec

/** {@inheritDoc} */
public void warn(String format, Object ... params) {
if (AnsiConsole.isInstalled()) {
if (isAnsiConsoleInstalled()) {
log.warn(colored(format, WARNING, params));
} else {
fallbackLogger.warn(format, params);
Expand All @@ -122,7 +122,7 @@ public void warn(String format, Object ... params) {

/** {@inheritDoc} */
public void error(String message, Object ... params) {
if (AnsiConsole.isInstalled()) {
if (isAnsiConsoleInstalled()) {
log.error(colored(message, ERROR, params));
} else {
fallbackLogger.error(message, params);
Expand Down Expand Up @@ -161,7 +161,7 @@ public void progressStart() {
@Override
public void progressUpdate(String layerId, String status, String progressMessage) {
if (!batchMode && log.isInfoEnabled() && StringUtils.isNotEmpty(layerId)) {
if (useAnsi && AnsiConsole.isInstalled()) {
if (useAnsi && isAnsiConsoleInstalled()) {
updateAnsiProgress(layerId, status, progressMessage);
} else {
updateNonAnsiProgress();
Expand Down Expand Up @@ -287,4 +287,15 @@ private List<LogVerboseCategory> getVerboseModesFromString(String groups) {
}
return ret;
}

private static boolean isAnsiConsoleInstalled() {
// Maven 3.6.3 uses jansi 1.17 which doesn't include this method
try {
AnsiConsole.class.getMethod("isInstalled");
return AnsiConsole.isInstalled();
} catch (NoSuchMethodException ex) {
// Assume AnsiConsole is always installed in case the method doesn't exist
return true;
}
}
}

0 comments on commit 2d53c34

Please sign in to comment.