Skip to content

Commit

Permalink
[MPMD-379] Deprecate parameter "showPmdLog"
Browse files Browse the repository at this point in the history
  • Loading branch information
adangel committed Apr 5, 2024
1 parent 00b9f13 commit ed944d5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 23 deletions.
16 changes: 16 additions & 0 deletions src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,20 @@ public abstract class AbstractPmdReport extends AbstractMavenReport {
* the PMD logger is also configured for debug.
*
* @since 3.9.0
* @deprecated With 3.22.0 and the upgrade to PMD 7, this parameter has no effect anymore. The PMD log
* is now always redirected into the maven log and this can't be disabled by this parameter anymore.
* In order to disable the logging, see <a href="https://maven.apache.org/maven-logging.html">Maven Logging</a>.
* You'd need to start maven with <code>MAVEN_OPTS=-Dorg.slf4j.simpleLogger.log.net.sourceforge.pmd=off mvn &lt;goals&gt;</code>.
*/
@Parameter(defaultValue = "true", property = "pmd.showPmdLog")
@Deprecated(since = "3.22.0", forRemoval = true)
protected boolean showPmdLog = true;

/**
* Used to avoid showing the deprecation warning for "showPmdLog" multiple times.
*/
private boolean warnedAboutShowPmdLog = false;

/**
* <p>
* Allow for configuration of the jvm used to run PMD via maven toolchains.
Expand Down Expand Up @@ -454,6 +464,12 @@ protected boolean isXml() {
*/
@Override
public boolean canGenerateReport() {
if (!showPmdLog && !warnedAboutShowPmdLog) {
getLog().warn("The parameter \"showPmdLog\" has been deprecated and will be removed."
+ "Setting it to \"false\" has no effect.");
warnedAboutShowPmdLog = true;
}

if (aggregate && !project.isExecutionRoot()) {
return false;
}
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/org/apache/maven/plugins/pmd/CpdReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,7 @@ private void executeCpd() throws MavenReportException {
request.setIgnoreLiterals(ignoreLiterals);
request.setSourceEncoding(getInputEncoding());
request.addFiles(filesToProcess.keySet());

request.setShowPmdLog(showPmdLog);
request.setLogLevel(determineCurrentRootLogLevel());

request.setExcludeFromFailureFile(excludeFromFailureFile);
request.setTargetDirectory(targetDirectory.getAbsolutePath());
request.setOutputEncoding(getOutputEncoding());
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 @@ -366,11 +366,9 @@ private void executePmd() throws MavenReportException {
request.setBenchmarkOutputLocation(benchmark ? benchmarkOutputFilename : null);
request.setAnalysisCacheLocation(analysisCache ? analysisCacheLocation : null);
request.setExcludeFromFailureFile(excludeFromFailureFile);

request.setTargetDirectory(targetDirectory.getAbsolutePath());
request.setOutputEncoding(getOutputEncoding());
request.setFormat(format);
request.setShowPmdLog(showPmdLog);
request.setSkipPmdError(skipPmdError);
request.setIncludeXmlInSite(includeXmlInSite);
request.setReportOutputDirectory(getReportOutputDirectory().getAbsolutePath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public class CpdRequest implements Serializable {
private String sourceEncoding;
private List<File> files = new ArrayList<>();

private boolean showPmdLog;
private String logLevel;

private String excludeFromFailureFile;
Expand Down Expand Up @@ -105,10 +104,6 @@ public void setReportOutputDirectory(String reportOutputDirectory) {
this.reportOutputDirectory = reportOutputDirectory;
}

public void setShowPmdLog(boolean showPmdLog) {
this.showPmdLog = showPmdLog;
}

public void setLogLevel(String logLevel) {
this.logLevel = logLevel;
}
Expand Down Expand Up @@ -161,10 +156,6 @@ public String getReportOutputDirectory() {
return reportOutputDirectory;
}

public boolean isShowPmdLog() {
return showPmdLog;
}

public String getLogLevel() {
return logLevel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public class PmdRequest implements Serializable {
private String sourceEncoding;
private List<File> files = new ArrayList<>();

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

Expand Down Expand Up @@ -126,10 +125,6 @@ public void setFormat(String format) {
this.format = format;
}

public void setShowPmdLog(boolean showPmdLog) {
this.showPmdLog = showPmdLog;
}

public void setLogLevel(String logLevel) {
this.logLevel = logLevel;
}
Expand Down Expand Up @@ -206,10 +201,6 @@ public String getFormat() {
return format;
}

public boolean isShowPmdLog() {
return showPmdLog;
}

public String getLogLevel() {
return logLevel;
}
Expand Down

0 comments on commit ed944d5

Please sign in to comment.