[ https://issues.apache.org/jira/browse/MNG-6380?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17241595#comment-17241595 ]
Michael Osipov edited comment on MNG-6380 at 12/1/20, 3:03 PM: --------------------------------------------------------------- This makes sense since from my POV Jansi should only be active when the (explicit) install has happened. I wonder how this would exactly work because in MavenCli we do: {code} public static int main( String[] args, ClassWorld classWorld ) { MavenCli cli = new MavenCli(); MessageUtils.systemInstall(); MessageUtils.registerShutdownHook(); int result = cli.doMain( new CliRequest( args, classWorld ) ); MessageUtils.systemUninstall(); return result; } {code} then later we do in this class: {code} // LOG COLOR String styleColor = cliRequest.getUserProperties().getProperty( STYLE_COLOR_PROPERTY, "auto" ); if ( "always".equals( styleColor ) ) { MessageUtils.setColorEnabled( true ); } else if ( "never".equals( styleColor ) ) { MessageUtils.setColorEnabled( false ); } else if ( !"auto".equals( styleColor ) ) { throw new IllegalArgumentException( "Invalid color configuration option [" + styleColor + "]. Supported values are (auto|always|never)." ); } else if ( cliRequest.commandLine.hasOption( CLIManager.BATCH_MODE ) || cliRequest.commandLine.hasOption( CLIManager.LOG_FILE ) ) { MessageUtils.setColorEnabled( false ); } {code} This would require to remove the static block from {{AnsiConsole}}, correct? But I am still not certain how this would solve our problem because even w/o the eager init, it would be still too late, wouldn't be it. It seems like this would require some change with {{MavenCli}}. was (Author: michael-o): This makes sense since from my POV Jansi should only be active when the (explicit) install has happened. I wonder how this would exactly work because in MavenCli we do: {code:java} public static int main( String[] args, ClassWorld classWorld ) { MavenCli cli = new MavenCli(); MessageUtils.systemInstall(); MessageUtils.registerShutdownHook(); int result = cli.doMain( new CliRequest( args, classWorld ) ); MessageUtils.systemUninstall(); return result; } {code} then later we do in this class: {code;java} // LOG COLOR String styleColor = cliRequest.getUserProperties().getProperty( STYLE_COLOR_PROPERTY, "auto" ); if ( "always".equals( styleColor ) ) { MessageUtils.setColorEnabled( true ); } else if ( "never".equals( styleColor ) ) { MessageUtils.setColorEnabled( false ); } else if ( !"auto".equals( styleColor ) ) { throw new IllegalArgumentException( "Invalid color configuration option [" + styleColor + "]. Supported values are (auto|always|never)." ); } else if ( cliRequest.commandLine.hasOption( CLIManager.BATCH_MODE ) || cliRequest.commandLine.hasOption( CLIManager.LOG_FILE ) ) { MessageUtils.setColorEnabled( false ); } {code} This would require to remove the static block from {{AnsiConsole}}, correct? But I am still not certain how this would solve our problem because even w/o the eager init, it would be still too late, wouldn't be it. It seems like this would require some change with {{MavenCli}}. > Option -Dstyle.color=always doesn't force color output > ------------------------------------------------------ > > Key: MNG-6380 > URL: https://issues.apache.org/jira/browse/MNG-6380 > Project: Maven > Issue Type: Improvement > Affects Versions: 3.5.3 > Reporter: Henning Hoefer > Priority: Minor > Labels: workaround-exists > > When the output is not a TTY (e.g. on a CI server), the new option > {{-Dstyle.color=always}} doesn't work, because JAnsi itself is disabling its > color output. > {code:bash} > # OK, produces color: > mvn -B -Dstyle.color=always package > # FAIL, doesn't produce color: > mvn -B -Dstyle.color=always package | less -R > # WORKAROUND: > MAVEN_OPTS=-Djansi.force=true mvn -B -Dstyle.color=always package | less -R > {code} > The {{-Dstyle.color=always}} option needs to imply {{-Djansi.force=true}} – > otherwise, "always" doesn't really mean always. > The problem for the implementation is, that the JAnsi option needs to be set > as a system property way early during startup. -- This message was sent by Atlassian Jira (v8.3.4#803005)