add methods to manage colors consistently across plugins

git-svn-id: https://svn.apache.org/repos/asf/maven/shared/trunk@1748766 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/maven/shared/project/utils/AnsiUtils.java b/src/main/java/org/apache/maven/shared/project/utils/AnsiUtils.java
index 5fa4401..1189c25 100644
--- a/src/main/java/org/apache/maven/shared/project/utils/AnsiUtils.java
+++ b/src/main/java/org/apache/maven/shared/project/utils/AnsiUtils.java
@@ -24,14 +24,27 @@
 import org.fusesource.jansi.AnsiConsole;
 
 /**
- * Ansi color utils, to enable colors only if Maven version is at least 3.4.
+ * Ansi color utils, to manage colors colors consistently across plugins (only if Maven version is at least 3.4).
  */
 public class AnsiUtils
 {
     private static final String MINIMUM_MAVEN_VERSION = "3.4.0"; // color added in Maven 3.4.0: see MNG-3507
 
+    private Ansi ansi;
+
     private AnsiUtils()
     {
+        ansi = new Ansi();
+    }
+
+    private AnsiUtils( StringBuilder builder )
+    {
+        ansi = new Ansi( builder );
+    }
+
+    private AnsiUtils( int size )
+    {
+        ansi = new Ansi( size );
     }
 
     public static void systemInstall()
@@ -48,4 +61,202 @@
     {
         AnsiConsole.systemUninstall();
     }
+
+    public static AnsiUtils ansi()
+    {
+        return new AnsiUtils();
+    }
+
+    public static AnsiUtils ansi( StringBuilder builder )
+    {
+        return new AnsiUtils( builder );
+    }
+
+    public static AnsiUtils ansi( int size )
+    {
+        return new AnsiUtils( size );
+    }
+
+    //
+    // consistent color management
+    // TODO make configurable
+    // settings.xml? during systemInstall(Settings)?
+    // or project properties (that can be injected by settings)?
+    //
+    /**
+     * Insert color for DEBUG level display.
+     * @return by default, bold cyan
+     */
+    public AnsiUtils debug()
+    {
+        ansi.bold().fgCyan();
+        return this;
+    }
+    
+    /**
+     * Insert color for INFO level display.
+     * @return by default, bold blue
+     */
+    public AnsiUtils info()
+    {
+        ansi.bold().fgBlue();
+        return this;
+    }
+    
+    /**
+     * Insert color for WARNING level or warning message display.
+     * @return by default, bold yellow
+     */
+    public AnsiUtils warning()
+    {
+        ansi.bold().fgYellow();
+        return this;
+    }
+    
+    /**
+     * Insert color for ERROR level display.
+     * @return by default, bold red
+     */
+    public AnsiUtils error()
+    {
+        ansi.bold().fgRed();
+        return this;
+    }
+    
+    /**
+     * Insert color for success message display.
+     * @return by default, bold green
+     */
+    public AnsiUtils success()
+    {
+        ansi.bold().fgGreen();
+        return this;
+    }
+    
+    /**
+     * Insert color for failure message display.
+     * @return by default, bold red
+     */
+    public AnsiUtils failure()
+    {
+        ansi.bold().fgRed();
+        return this;
+    }
+
+    /**
+     * Insert color for highlighted message display.
+     * @return by default, bold
+     */
+    public AnsiUtils highlight()
+    {
+        ansi.bold();
+        return this;
+    }
+
+    /**
+     * Insert color for mojo message display.
+     * @return by default, green
+     */
+    public AnsiUtils mojo()
+    {
+        ansi.fgGreen();
+        return this;
+    }
+
+    /**
+     * Insert color for project message display.
+     * @return by default, cyan
+     */
+    public AnsiUtils project()
+    {
+        ansi.fgCyan();
+        return this;
+    }
+
+    //
+    // message building methods (modelled after Ansi methods)
+    //
+    public AnsiUtils reset()
+    {
+        ansi.reset();
+        return this;
+    }
+
+    public AnsiUtils a( boolean value )
+    {
+        ansi.a( value );
+        return this;
+    }
+
+    public AnsiUtils a( char value )
+    {
+        ansi.a( value );
+        return this;
+    }
+
+    public AnsiUtils a( char[] value, int offset, int len )
+    {
+        ansi.a( value, offset, len );
+        return this;
+    }
+
+    public AnsiUtils a( char[] value )
+    {
+        ansi.a( value );
+        return this;
+    }
+
+    public AnsiUtils a( CharSequence value, int start, int end )
+    {
+        ansi.a( value, start, end );
+        return this;
+    }
+
+    public AnsiUtils a( CharSequence value )
+    {
+        ansi.a( value );
+        return this;
+    }
+
+    public AnsiUtils a( double value )
+    {
+        ansi.a( value );
+        return this;
+    }
+
+    public AnsiUtils a( float value )
+    {
+        ansi.a( value );
+        return this;
+    }
+
+    public AnsiUtils a( int value )
+    {
+        ansi.a( value );
+        return this;
+    }
+
+    public AnsiUtils a( long value )
+    {
+        ansi.a( value );
+        return this;
+    }
+
+    public AnsiUtils a( Object value )
+    {
+        ansi.a( value );
+        return this;
+    }
+
+    public AnsiUtils newline()
+    {
+        ansi.newline();
+        return this;
+    }
+
+    public AnsiUtils format( String pattern, Object... args )
+    {
+        ansi.format( pattern, args );
+        return this;
+    }
 }