Class MessageUtils
- java.lang.Object
-
- org.apache.maven.shared.utils.logging.MessageUtils
-
public class MessageUtils extends java.lang.Object
Colored message utils, to manage colors consistently across plugins (only if Maven version is at least 3.5.0). For Maven version before 3.5.0, message built with this util will never add color.Internally, Jansi is used to render ANSI colors on any platform.
- Since:
- 3.1.0
-
-
Constructor Summary
Constructors Constructor Description MessageUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static MessageBuilder
buffer()
Create a default message buffer.static MessageBuilder
buffer(int size)
Create a message buffer with an internal buffer of defined size.static MessageBuilder
buffer(java.lang.StringBuilder builder)
Create a message buffer with defined String builder.static boolean
isColorEnabled()
Is message color enabled: requires JAnsi available (through Maven) and the color has not been disabled.static LoggerLevelRenderer
level()
Create a logger level renderer.static void
registerShutdownHook()
Register a shutdown hook with the JVM runtime, uninstalling Ansi support on JVM shutdown unless is has already been uninstalled at that time.static void
setColorEnabled(boolean flag)
Enables message color (if JAnsi is available).static java.lang.String
stripAnsiCodes(java.lang.String msg)
Remove any ANSI code from a message (colors or other escape sequences).static void
systemInstall()
Install color support.static void
systemUninstall()
Undo a previoussystemInstall()
.
-
-
-
Method Detail
-
systemInstall
public static void systemInstall()
Install color support. This method is called by Maven core, and calling it is not necessary in plugins.
-
systemUninstall
public static void systemUninstall()
Undo a previoussystemInstall()
. IfsystemInstall()
was called multiple times,systemUninstall()
must be called call the same number of times before it is actually uninstalled.
-
setColorEnabled
public static void setColorEnabled(boolean flag)
Enables message color (if JAnsi is available).- Parameters:
flag
-
-
isColorEnabled
public static boolean isColorEnabled()
Is message color enabled: requires JAnsi available (through Maven) and the color has not been disabled.
-
buffer
public static MessageBuilder buffer()
Create a default message buffer.- Returns:
- a new buffer
-
buffer
public static MessageBuilder buffer(java.lang.StringBuilder builder)
Create a message buffer with defined String builder.- Returns:
- a new buffer
-
buffer
public static MessageBuilder buffer(int size)
Create a message buffer with an internal buffer of defined size.- Returns:
- a new buffer
-
level
public static LoggerLevelRenderer level()
Create a logger level renderer.- Returns:
- a logger level renderer
- Since:
- 3.2.0
-
stripAnsiCodes
public static java.lang.String stripAnsiCodes(java.lang.String msg)
Remove any ANSI code from a message (colors or other escape sequences).- Parameters:
msg
- message eventually containing ANSI codes- Returns:
- the message with ANSI codes removed
-
registerShutdownHook
public static void registerShutdownHook()
Register a shutdown hook with the JVM runtime, uninstalling Ansi support on JVM shutdown unless is has already been uninstalled at that time.Delegates to
doSystemUninstall()
for the actual uninstall procedure- See Also:
Runtime.addShutdownHook(Thread)
,systemUninstall()
,doSystemUninstall()
-
-