Skip to content

Commit

Permalink
[MPMD-353] - API incompatibility with jansi after upgrading m-shared-…
Browse files Browse the repository at this point in the history
…utils (#91)

The call to `MessageUtils.setColorEnabled()` is not needed. Log output
from PMD is correctly colored depending on the maven settings.
No special handling is needed.
  • Loading branch information
adangel authored Sep 1, 2022
1 parent 1d7a2fb commit 7b4c330
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 32 deletions.
2 changes: 0 additions & 2 deletions src/main/java/org/apache/maven/plugins/pmd/CpdReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.apache.maven.plugins.pmd.exec.CpdRequest;
import org.apache.maven.plugins.pmd.exec.CpdResult;
import org.apache.maven.reporting.MavenReportException;
import org.apache.maven.shared.utils.logging.MessageUtils;
import org.apache.maven.toolchain.Toolchain;

import net.sourceforge.pmd.cpd.JavaTokenizer;
Expand Down Expand Up @@ -211,7 +210,6 @@ private void executeCpd()
request.addFiles( filesToProcess.keySet() );

request.setShowPmdLog( showPmdLog );
request.setColorizedLog( MessageUtils.isColorEnabled() );
request.setLogLevel( determineCurrentRootLogLevel() );

request.setExcludeFromFailureFile( excludeFromFailureFile );
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter;
import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult;
import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver;
import org.apache.maven.shared.utils.logging.MessageUtils;
import org.apache.maven.toolchain.Toolchain;
import org.codehaus.plexus.resource.ResourceManager;
import org.codehaus.plexus.resource.loader.FileResourceCreationException;
Expand Down Expand Up @@ -374,7 +373,6 @@ private void executePmd()
request.setOutputEncoding( getOutputEncoding() );
request.setFormat( format );
request.setShowPmdLog( showPmdLog );
request.setColorizedLog( MessageUtils.isColorEnabled() );
request.setSkipPmdError( skipPmdError );
request.setIncludeXmlInSite( includeXmlInSite );
request.setReportOutputDirectory( getReportOutputDirectory().getAbsolutePath() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public CpdExecutor( CpdRequest request )

private CpdResult run() throws MavenReportException
{
setupPmdLogging( request.isShowPmdLog(), request.isColorizedLog(), request.getLogLevel() );
setupPmdLogging( request.isShowPmdLog(), request.getLogLevel() );

try
{
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/org/apache/maven/plugins/pmd/exec/CpdRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public class CpdRequest implements Serializable
private List<File> files = new ArrayList<>();

private boolean showPmdLog;
private boolean colorizedLog;
private String logLevel;

private String excludeFromFailureFile;
Expand Down Expand Up @@ -122,11 +121,6 @@ public void setShowPmdLog( boolean showPmdLog )
this.showPmdLog = showPmdLog;
}

public void setColorizedLog( boolean colorizedLog )
{
this.colorizedLog = colorizedLog;
}

public void setLogLevel( String logLevel )
{
this.logLevel = logLevel;
Expand Down Expand Up @@ -197,11 +191,6 @@ public boolean isShowPmdLog()
return showPmdLog;
}

public boolean isColorizedLog()
{
return colorizedLog;
}

public String getLogLevel()
{
return logLevel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

import org.apache.maven.cli.logging.Slf4jConfiguration;
import org.apache.maven.cli.logging.Slf4jConfigurationFactory;
import org.apache.maven.shared.utils.logging.MessageUtils;
import org.codehaus.plexus.logging.console.ConsoleLogger;
import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;
Expand All @@ -54,10 +53,8 @@ abstract class Executor
*/
private java.util.logging.Logger julLogger;

protected void setupPmdLogging( boolean showPmdLog, boolean colorizedLog, String logLevel )
protected void setupPmdLogging( boolean showPmdLog, String logLevel )
{
MessageUtils.setColorEnabled( colorizedLog );

if ( !showPmdLog )
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public PmdExecutor( PmdRequest request )

private PmdResult run() throws MavenReportException
{
setupPmdLogging( request.isShowPmdLog(), request.isColorizedLog(), request.getLogLevel() );
setupPmdLogging( request.isShowPmdLog(), request.getLogLevel() );

PMDConfiguration configuration = new PMDConfiguration();
LanguageVersion languageVersion = null;
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/org/apache/maven/plugins/pmd/exec/PmdRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public class PmdRequest implements Serializable
private List<File> files = new ArrayList<>();

private boolean showPmdLog;
private boolean colorizedLog;
private String logLevel;
private boolean skipPmdError;

Expand Down Expand Up @@ -154,11 +153,6 @@ public void setShowPmdLog( boolean showPmdLog )
this.showPmdLog = showPmdLog;
}

public void setColorizedLog( boolean colorizedLog )
{
this.colorizedLog = colorizedLog;
}

public void setLogLevel( String logLevel )
{
this.logLevel = logLevel;
Expand Down Expand Up @@ -263,11 +257,6 @@ public boolean isShowPmdLog()
return showPmdLog;
}

public boolean isColorizedLog()
{
return colorizedLog;
}

public String getLogLevel()
{
return logLevel;
Expand Down

0 comments on commit 7b4c330

Please sign in to comment.