Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/maven-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ jobs:
build:
name: Verify
uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4
with:
maven4-enabled: true
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ under the License.
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<debug>false</debug>
<showErrors>true</showErrors>
<showVersion>true</showVersion>
<goals>
<goal>clean</goal>
<goal>site</goal>
Expand Down
4 changes: 4 additions & 0 deletions src/it/MPMD-323-ruleset-basedir-jgitver/invoker.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@

invoker.goals = clean verify
invoker.java.version = 11+

# TODO investigate on Maven 4
# [ERROR] detection of jgitver old setting mechanism: jgitver must now use maven core extensions only -> [Help 1]
invoker.maven.version=!4+
7 changes: 6 additions & 1 deletion src/it/MPMD-335-aggregate-classpath-repositories/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ under the License.
<repositories>
<repository>
<id>corp1</id>
<url>file://${user.dir}/private-repo</url>
<!-- we need a absolute path to repo -->
<url>@baseurl@/target/it/MPMD-335-aggregate-classpath-repositories/private-repo</url>
<snapshots>
<!-- required by Maven 4 -->
<checksumPolicy>ignore</checksumPolicy>
</snapshots>
</repository>
</repositories>
</project>
12 changes: 0 additions & 12 deletions src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -453,18 +453,6 @@ protected boolean canGenerateReportInternal() throws MavenReportException {
return true;
}

protected String determineCurrentRootLogLevel() {
String logLevel = System.getProperty("org.slf4j.simpleLogger.defaultLogLevel");
if (logLevel == null) {
logLevel = System.getProperty("maven.logging.root.level");
}
if (logLevel == null) {
// TODO: logback level
logLevel = "info";
}
return logLevel;
}

static String getPmdVersion() {
return PMDVersion.VERSION;
}
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/apache/maven/plugins/pmd/CpdReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ private void executeCpd() throws MavenReportException {
request.setIgnoreLiterals(ignoreLiterals);
request.setSourceEncoding(getInputEncoding());
request.addFiles(filesToProcess.keySet());
request.setLogLevel(determineCurrentRootLogLevel());
request.setExcludeFromFailureFile(excludeFromFailureFile);
request.setTargetDirectory(targetDirectory.getAbsolutePath());
request.setOutputEncoding(getOutputEncoding());
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ private void executePmd() throws MavenReportException {
request.setSkipPmdError(skipPmdError);
request.setIncludeXmlInReports(includeXmlInReports);
request.setReportOutputDirectory(getReportOutputDirectory().getAbsolutePath());
request.setLogLevel(determineCurrentRootLogLevel());
request.setJdkToolchain(getJdkToolchain());

getLog().info("PMD version: " + AbstractPmdReport.getPmdVersion());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public static void main(String[] args) {
try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(requestFile))) {
CpdRequest request = (CpdRequest) in.readObject();
CpdExecutor cpdExecutor = new CpdExecutor(request);
cpdExecutor.setupLogLevel(request.getLogLevel());
cpdExecutor.run();
System.exit(0);
} catch (IOException | ClassNotFoundException | MavenReportException e) {
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/org/apache/maven/plugins/pmd/exec/CpdRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public class CpdRequest implements Serializable {
private String sourceEncoding;
private List<File> files = new ArrayList<>();

private String logLevel;

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

public void setLogLevel(String logLevel) {
this.logLevel = logLevel;
}

public Map<String, String> getJdkToolchain() {
return jdkToolchain;
}
Expand Down Expand Up @@ -157,10 +151,6 @@ public String getReportOutputDirectory() {
return reportOutputDirectory;
}

public String getLogLevel() {
return logLevel;
}

public boolean isIgnoreAnnotations() {
return ignoreAnnotations;
}
Expand Down
23 changes: 2 additions & 21 deletions src/main/java/org/apache/maven/plugins/pmd/exec/Executor.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,9 @@
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;

import org.apache.maven.cli.logging.Slf4jConfiguration;
import org.apache.maven.cli.logging.Slf4jConfigurationFactory;
import org.codehaus.plexus.logging.console.ConsoleLogger;
import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

abstract class Executor {
private static final Logger LOG = LoggerFactory.getLogger(Executor.class);

protected void setupLogLevel(String logLevel) {
ILoggerFactory slf4jLoggerFactory = LoggerFactory.getILoggerFactory();
Slf4jConfiguration slf4jConfiguration = Slf4jConfigurationFactory.getConfiguration(slf4jLoggerFactory);
if ("debug".equals(logLevel)) {
slf4jConfiguration.setRootLoggerLevel(Slf4jConfiguration.Level.DEBUG);
} else if ("info".equals(logLevel)) {
slf4jConfiguration.setRootLoggerLevel(Slf4jConfiguration.Level.INFO);
} else {
slf4jConfiguration.setRootLoggerLevel(Slf4jConfiguration.Level.ERROR);
}
slf4jConfiguration.activate();
}

protected static String buildClasspath() {
StringBuilder classpath = new StringBuilder();
Expand All @@ -74,7 +55,7 @@ static void buildClasspath(StringBuilder classpath, ClassLoader cl) {
String filename = URLDecoder.decode(url.getPath(), StandardCharsets.UTF_8.name());
classpath.append(new File(filename).getPath()).append(File.pathSeparatorChar);
} catch (UnsupportedEncodingException e) {
LOG.warn("Ignoring " + url + " in classpath due to UnsupportedEncodingException", e);
// skip as we provide the correct standard encoding
}
}
}
Expand Down Expand Up @@ -109,7 +90,7 @@ public void run() {
}
out.flush();
} catch (IOException e) {
LOG.error(e.getMessage(), e);
e.printStackTrace();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public static void main(String[] args) {
try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(requestFile))) {
PmdRequest request = (PmdRequest) in.readObject();
PmdExecutor pmdExecutor = new PmdExecutor(request);
pmdExecutor.setupLogLevel(request.getLogLevel());
pmdExecutor.run();
System.exit(0);
} catch (IOException | ClassNotFoundException | MavenReportException e) {
Expand Down