diff --git a/pom.xml b/pom.xml
index b0c3c593..543724a2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -85,12 +85,12 @@ under the License.
8
7.0.0
1.7.36
+ 2.0.0-M8
1.0.0.v20140518
- 1.12.0
3.11.0
- 3.12.1
- 3.4.3
- 3.3.0
+ 4.0.0-M13
+ 4.0.0-M1-SNAPSHOT
+ 4.0.0-M1-SNAPSHOT
2024-04-18T10:13:24Z
@@ -193,55 +193,18 @@ under the License.
org.apache.maven.doxia
doxia-sink-api
${doxiaVersion}
-
-
- org.codehaus.plexus
- plexus-container-default
-
-
org.apache.maven.doxia
doxia-core
${doxiaVersion}
-
-
- org.codehaus.plexus
- plexus-container-default
-
-
-
-
- org.apache.maven.doxia
- doxia-site-renderer
- 1.11.1
- runtime
-
-
-
- org.apache.httpcomponents
- httpclient
-
-
- org.codehaus.plexus
- plexus-container-default
-
-
- org.codehaus.plexus
- plexus-component-api
-
-
org.apache.maven.reporting
maven-reporting-impl
- 3.2.0
+ 4.0.0-M13
diff --git a/src/it/MPMD-165/verify.groovy b/src/it/MPMD-165/verify.groovy
index 116a28f5..94cc1d66 100644
--- a/src/it/MPMD-165/verify.groovy
+++ b/src/it/MPMD-165/verify.groovy
@@ -17,7 +17,7 @@
* under the License.
*/
-File pmdHtml = new File( basedir, "target/site/pmd.html" );
+File pmdHtml = new File( basedir, "target/reports/pmd.html" );
assert pmdHtml.exists()
// Groovy's getText() automatically detects the correct encoding, so that UTF-16 works out of the box
diff --git a/src/it/MPMD-289-format-html-check/verify.groovy b/src/it/MPMD-289-format-html-check/verify.groovy
index 04afaaeb..aa62e282 100644
--- a/src/it/MPMD-289-format-html-check/verify.groovy
+++ b/src/it/MPMD-289-format-html-check/verify.groovy
@@ -24,11 +24,11 @@ assert buildLog.exists()
File pmdXml = new File( basedir, 'target/pmd.xml' )
assert pmdXml.exists()
-File pmdHtmlReport = new File ( basedir, 'target/site/pmd.html' )
+File pmdHtmlReport = new File ( basedir, 'target/reports/pmd.html' )
assert pmdHtmlReport.exists()
File cpdXml = new File( basedir, 'target/cpd.xml' )
assert cpdXml.exists()
-File cpdHtmlReport = new File ( basedir, 'target/site/cpd.html' )
+File cpdHtmlReport = new File ( basedir, 'target/reports/cpd.html' )
assert cpdHtmlReport.exists()
diff --git a/src/it/MPMD-304-toolchain-support/verify.groovy b/src/it/MPMD-304-toolchain-support/verify.groovy
index 21aa3491..9518738e 100644
--- a/src/it/MPMD-304-toolchain-support/verify.groovy
+++ b/src/it/MPMD-304-toolchain-support/verify.groovy
@@ -32,18 +32,18 @@ assert pmdReport.exists()
assert pmdReport.text.contains( 'MPMD-80 included
- Test that the cpd.xml and pmd.xml files are included in the generated site.
+ Test that the cpd.xml and pmd.xml files are included in the generated reports output directory.
@@ -48,7 +48,7 @@ under the License.
@project.version@
false
- true
+ true
diff --git a/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java b/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java
index 87c40d85..ce91e235 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java
@@ -39,6 +39,7 @@
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.model.Reporting;
+import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
@@ -159,12 +160,12 @@ public abstract class AbstractPmdReport extends AbstractMavenReport {
protected boolean aggregate;
/**
- * Whether to include the xml files generated by PMD/CPD in the site.
+ * Whether to include the XML files generated by PMD/CPD in the {@link #getReportOutputDirectory()}.
*
* @since 3.0
*/
@Parameter(defaultValue = "false")
- protected boolean includeXmlInSite;
+ protected boolean includeXmlInReports;
/**
* Skip the PMD/CPD report generation if there are no violations or duplications found. Defaults to
@@ -251,12 +252,6 @@ public abstract class AbstractPmdReport extends AbstractMavenReport {
// Read-only parameters
// ----------------------------------------------------------------------
- /**
- * The projects in the reactor for aggregation report.
- */
- @Parameter(property = "reactorProjects", readonly = true)
- protected List reactorProjects;
-
/**
* The current build session instance. This is used for
* toolchain manager API calls and for dependency resolver API calls.
@@ -275,6 +270,14 @@ protected MavenProject getProject() {
return project;
}
+ protected List getReactorProjects() {
+ return reactorProjects;
+ }
+
+ protected MojoExecution getMojoExecution() {
+ return mojoExecution;
+ }
+
protected String constructXRefLocation(boolean test) {
String location = null;
if (linkXRef) {
@@ -459,11 +462,7 @@ protected boolean isXml() {
return "xml".equals(format);
}
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean canGenerateReport() {
+ protected boolean canGenerateReportInternal() throws MavenReportException {
if (!showPmdLog && !warnedAboutShowPmdLog) {
getLog().warn("The parameter \"showPmdLog\" has been deprecated and will be removed."
+ "Setting it to \"false\" has no effect.");
@@ -489,7 +488,7 @@ public boolean canGenerateReport() {
return false;
}
} catch (IOException e) {
- getLog().error(e);
+ throw new MavenReportException("Failed to determine files to process for PMD", e);
}
return true;
}
diff --git a/src/main/java/org/apache/maven/plugins/pmd/CpdReport.java b/src/main/java/org/apache/maven/plugins/pmd/CpdReport.java
index 8c003641..5fd35a1e 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/CpdReport.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/CpdReport.java
@@ -144,24 +144,16 @@ public void executeReport(Locale locale) throws MavenReportException {
}
@Override
- public boolean canGenerateReport() {
+ public boolean canGenerateReport() throws MavenReportException {
if (skip) {
- getLog().info("Skipping CPD execution");
return false;
}
- boolean result = super.canGenerateReport();
+ boolean result = canGenerateReportInternal();
if (result) {
- try {
- executeCpd();
- if (skipEmptyReport) {
- result = cpdResult.hasDuplications();
- if (!result) {
- getLog().debug("Skipping report since skipEmptyReport is true and there are no CPD issues.");
- }
- }
- } catch (MavenReportException e) {
- throw new RuntimeException(e);
+ executeCpd();
+ if (skipEmptyReport) {
+ result = cpdResult.hasDuplications();
}
}
return result;
@@ -190,7 +182,7 @@ private void executeCpd() throws MavenReportException {
request.setTargetDirectory(targetDirectory.getAbsolutePath());
request.setOutputEncoding(getOutputEncoding());
request.setFormat(format);
- request.setIncludeXmlInSite(includeXmlInSite);
+ request.setIncludeXmlInReports(includeXmlInReports);
request.setReportOutputDirectory(getReportOutputDirectory().getAbsolutePath());
Toolchain tc = getToolchain();
diff --git a/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java b/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
index 5b3a14c8..f2bb1f01 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
@@ -313,25 +313,16 @@ public void executeReport(Locale locale) throws MavenReportException {
}
@Override
- public boolean canGenerateReport() {
+ public boolean canGenerateReport() throws MavenReportException {
if (skip) {
- getLog().info("Skipping PMD execution");
return false;
}
- boolean result = super.canGenerateReport();
+ boolean result = canGenerateReportInternal();
if (result) {
- try {
- executePmd();
- if (skipEmptyReport) {
- result = pmdResult.hasViolations();
- if (!result) {
- getLog().debug("Skipping report since skipEmptyReport is true and "
- + "there are no PMD violations.");
- }
- }
- } catch (MavenReportException e) {
- throw new RuntimeException(e);
+ executePmd();
+ if (skipEmptyReport) {
+ result = pmdResult.hasViolations();
}
}
return result;
@@ -370,7 +361,7 @@ private void executePmd() throws MavenReportException {
request.setOutputEncoding(getOutputEncoding());
request.setFormat(format);
request.setSkipPmdError(skipPmdError);
- request.setIncludeXmlInSite(includeXmlInSite);
+ request.setIncludeXmlInReports(includeXmlInReports);
request.setReportOutputDirectory(getReportOutputDirectory().getAbsolutePath());
request.setLogLevel(determineCurrentRootLogLevel());
diff --git a/src/main/java/org/apache/maven/plugins/pmd/exec/CpdExecutor.java b/src/main/java/org/apache/maven/plugins/pmd/exec/CpdExecutor.java
index 3cdd5758..d356797d 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/exec/CpdExecutor.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/exec/CpdExecutor.java
@@ -194,7 +194,7 @@ private CpdResult run() throws MavenReportException {
private void writeXmlReport(CPDReport cpd) throws MavenReportException {
File targetFile = writeReport(cpd, new XMLRenderer(request.getOutputEncoding()), "xml");
- if (request.isIncludeXmlInSite()) {
+ if (request.isIncludeXmlInReports()) {
File siteDir = new File(request.getReportOutputDirectory());
siteDir.mkdirs();
try {
diff --git a/src/main/java/org/apache/maven/plugins/pmd/exec/CpdRequest.java b/src/main/java/org/apache/maven/plugins/pmd/exec/CpdRequest.java
index 7ecc7109..32e3c396 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/exec/CpdRequest.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/exec/CpdRequest.java
@@ -50,7 +50,7 @@ public class CpdRequest implements Serializable {
private String targetDirectory;
private String outputEncoding;
private String format;
- private boolean includeXmlInSite;
+ private boolean includeXmlInReports;
private String reportOutputDirectory;
private boolean ignoreAnnotations;
private boolean ignoreIdentifiers;
@@ -96,8 +96,8 @@ public void setFormat(String format) {
this.format = format;
}
- public void setIncludeXmlInSite(boolean includeXmlInSite) {
- this.includeXmlInSite = includeXmlInSite;
+ public void setIncludeXmlInReports(boolean includeXmlInReports) {
+ this.includeXmlInReports = includeXmlInReports;
}
public void setReportOutputDirectory(String reportOutputDirectory) {
@@ -148,8 +148,8 @@ public String getFormat() {
return format;
}
- public boolean isIncludeXmlInSite() {
- return includeXmlInSite;
+ public boolean isIncludeXmlInReports() {
+ return includeXmlInReports;
}
public String getReportOutputDirectory() {
diff --git a/src/main/java/org/apache/maven/plugins/pmd/exec/PmdExecutor.java b/src/main/java/org/apache/maven/plugins/pmd/exec/PmdExecutor.java
index e6dacdbe..f71eac2c 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/exec/PmdExecutor.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/exec/PmdExecutor.java
@@ -315,11 +315,11 @@ private Report processFilesWithPMD(PMDConfiguration pmdConfiguration, List
*/
private void writeXmlReport(Report report) throws MavenReportException {
File targetFile = writeReport(report, new XMLRenderer(request.getOutputEncoding()));
- if (request.isIncludeXmlInSite()) {
- File siteDir = new File(request.getReportOutputDirectory());
- siteDir.mkdirs();
+ if (request.isIncludeXmlInReports()) {
+ File outputDirectory = new File(request.getReportOutputDirectory());
+ outputDirectory.mkdirs();
try {
- FileUtils.copyFile(targetFile, new File(siteDir, "pmd.xml"));
+ FileUtils.copyFile(targetFile, new File(outputDirectory, "pmd.xml"));
} catch (IOException e) {
throw new MavenReportException(e.getMessage(), e);
}
diff --git a/src/main/java/org/apache/maven/plugins/pmd/exec/PmdRequest.java b/src/main/java/org/apache/maven/plugins/pmd/exec/PmdRequest.java
index 07036577..1982e002 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/exec/PmdRequest.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/exec/PmdRequest.java
@@ -55,7 +55,7 @@ public class PmdRequest implements Serializable {
private String outputEncoding;
private String format;
private String benchmarkOutputLocation;
- private boolean includeXmlInSite;
+ private boolean includeXmlInReports;
private String reportOutputDirectory;
/**
@@ -133,8 +133,8 @@ public void setSkipPmdError(boolean skipPmdError) {
this.skipPmdError = skipPmdError;
}
- public void setIncludeXmlInSite(boolean includeXmlInSite) {
- this.includeXmlInSite = includeXmlInSite;
+ public void setIncludeXmlInReports(boolean includeXmlInReports) {
+ this.includeXmlInReports = includeXmlInReports;
}
public void setReportOutputDirectory(String reportOutputDirectory) {
@@ -213,8 +213,8 @@ public boolean isSkipPmdError() {
return skipPmdError;
}
- public boolean isIncludeXmlInSite() {
- return includeXmlInSite;
+ public boolean isIncludeXmlInReports() {
+ return includeXmlInReports;
}
public String getReportOutputDirectory() {
diff --git a/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTestCase.java b/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTestCase.java
index 18a22597..3c4bfd34 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTestCase.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTestCase.java
@@ -21,9 +21,15 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
+import java.util.Collections;
+import java.util.List;
import java.util.Locale;
+import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.LegacySupport;
+import org.apache.maven.plugin.MojoExecution;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
@@ -110,8 +116,17 @@ protected AbstractPmdReport createReportMojo(String goal, File pluginXmlFile) th
repoSession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory()
.newInstance(repoSession, new LocalRepository(artifactStubFactory.getWorkingDir())));
+ List reactorProjects =
+ mojo.getReactorProjects() != null ? mojo.getReactorProjects() : Collections.emptyList();
+
+ setVariableValueToObject(mojo, "mojoExecution", getMockMojoExecution());
setVariableValueToObject(mojo, "session", legacySupport.getSession());
- setVariableValueToObject(mojo, "remoteRepositories", mojo.getProject().getRemoteArtifactRepositories());
+ setVariableValueToObject(mojo, "repoSession", legacySupport.getRepositorySession());
+ setVariableValueToObject(mojo, "reactorProjects", reactorProjects);
+ setVariableValueToObject(
+ mojo, "remoteProjectRepositories", mojo.getProject().getRemoteProjectRepositories());
+ setVariableValueToObject(
+ mojo, "siteDirectory", new File(mojo.getProject().getBasedir(), "src/site"));
return mojo;
}
@@ -149,4 +164,22 @@ protected String readFile(File file) throws IOException {
public static boolean lowerCaseContains(String text, String contains) {
return text.toLowerCase(Locale.ROOT).contains(contains.toLowerCase(Locale.ROOT));
}
+
+ private MojoExecution getMockMojoExecution() {
+ MojoDescriptor md = new MojoDescriptor();
+ md.setGoal(getGoal());
+
+ MojoExecution me = new MojoExecution(md);
+
+ PluginDescriptor pd = new PluginDescriptor();
+ Plugin p = new Plugin();
+ p.setGroupId("org.apache.maven.plugins");
+ p.setArtifactId("maven-pmd-plugin");
+ pd.setPlugin(p);
+ md.setPluginDescriptor(pd);
+
+ return me;
+ }
+
+ protected abstract String getGoal();
}
diff --git a/src/test/java/org/apache/maven/plugins/pmd/CpdReportTest.java b/src/test/java/org/apache/maven/plugins/pmd/CpdReportTest.java
index b7657bf1..0a34957c 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/CpdReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/CpdReportTest.java
@@ -22,7 +22,6 @@
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File;
-import java.util.Locale;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
@@ -39,7 +38,6 @@ public class CpdReportTest extends AbstractPmdReportTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- Locale.setDefault(Locale.ENGLISH);
FileUtils.deleteDirectory(new File(getBasedir(), "target/test/unit"));
}
@@ -50,7 +48,7 @@ protected void setUp() throws Exception {
*/
public void testDefaultConfiguration() throws Exception {
File generatedReport =
- generateReport("cpd", "default-configuration/cpd-default-configuration-plugin-config.xml");
+ generateReport(getGoal(), "default-configuration/cpd-default-configuration-plugin-config.xml");
assertTrue(new File(generatedReport.getAbsolutePath()).exists());
// check if the CPD files were generated
@@ -75,7 +73,7 @@ public void testDefaultConfiguration() throws Exception {
* @throws Exception
*/
public void testTxtFormat() throws Exception {
- generateReport("cpd", "custom-configuration/cpd-txt-format-configuration-plugin-config.xml");
+ generateReport(getGoal(), "custom-configuration/cpd-txt-format-configuration-plugin-config.xml");
// check if the CPD files were generated
File generatedFile = new File(getBasedir(), "target/test/unit/custom-configuration/target/cpd.xml");
@@ -97,7 +95,8 @@ public void testTxtFormat() throws Exception {
* @throws Exception
*/
public void testCustomConfiguration() throws Exception {
- File generatedReport = generateReport("cpd", "custom-configuration/cpd-custom-configuration-plugin-config.xml");
+ File generatedReport =
+ generateReport(getGoal(), "custom-configuration/cpd-custom-configuration-plugin-config.xml");
assertTrue(new File(generatedReport.getAbsolutePath()).exists());
// check if the CPD files were generated
@@ -123,7 +122,7 @@ public void testInvalidFormat() throws Exception {
try {
File testPom = new File(
getBasedir(), "src/test/resources/unit/invalid-format/cpd-invalid-format-plugin-config.xml");
- AbstractPmdReport mojo = createReportMojo("cpd", testPom);
+ AbstractPmdReport mojo = createReportMojo(getGoal(), testPom);
setVariableValueToObject(
mojo, "compileSourceRoots", mojo.getProject().getCompileSourceRoots());
generateReport(mojo, testPom);
@@ -135,7 +134,7 @@ public void testInvalidFormat() throws Exception {
}
public void testWriteNonHtml() throws Exception {
- generateReport("cpd", "default-configuration/cpd-default-configuration-plugin-config.xml");
+ generateReport(getGoal(), "default-configuration/cpd-default-configuration-plugin-config.xml");
// check if the CPD files were generated
File generatedFile = new File(getBasedir(), "target/test/unit/default-configuration/target/cpd.xml");
@@ -153,11 +152,11 @@ public void testWriteNonHtml() throws Exception {
}
/**
- * verify the cpd.xml file is included in the site when requested.
+ * verify the cpd.xml file is included in the reports when requested.
* @throws Exception
*/
- public void testIncludeXmlInSite() throws Exception {
- generateReport("cpd", "default-configuration/cpd-report-include-xml-in-site-plugin-config.xml");
+ public void testIncludeXmlInReports() throws Exception {
+ generateReport(getGoal(), "default-configuration/cpd-report-include-xml-in-reports-config.xml");
File generatedFile = new File(getBasedir(), "target/test/unit/default-configuration/target/cpd.xml");
assertTrue(new File(generatedFile.getAbsolutePath()).exists());
@@ -178,13 +177,13 @@ public void testIncludeXmlInSite() throws Exception {
public void testSkipEmptyReportConfiguration() throws Exception {
// verify the generated files do not exist because PMD was skipped
- File generatedReport = generateReport("cpd", "empty-report/cpd-skip-empty-report-plugin-config.xml");
+ File generatedReport = generateReport(getGoal(), "empty-report/cpd-skip-empty-report-plugin-config.xml");
assertFalse(new File(generatedReport.getAbsolutePath()).exists());
}
public void testEmptyReportConfiguration() throws Exception {
// verify the generated files do exist, even if there are no violations
- File generatedReport = generateReport("cpd", "empty-report/cpd-empty-report-plugin-config.xml");
+ File generatedReport = generateReport(getGoal(), "empty-report/cpd-empty-report-plugin-config.xml");
assertTrue(new File(generatedReport.getAbsolutePath()).exists());
String str = readFile(generatedReport);
@@ -197,7 +196,7 @@ public void testCpdEncodingConfiguration() throws Exception {
try {
System.setProperty("file.encoding", "UTF-16");
- generateReport("cpd", "default-configuration/cpd-default-configuration-plugin-config.xml");
+ generateReport(getGoal(), "default-configuration/cpd-default-configuration-plugin-config.xml");
// check if the CPD files were generated
File generatedFile = new File(getBasedir(), "target/test/unit/default-configuration/target/cpd.xml");
@@ -210,7 +209,7 @@ public void testCpdEncodingConfiguration() throws Exception {
}
public void testCpdJavascriptConfiguration() throws Exception {
- generateReport("cpd", "default-configuration/cpd-javascript-plugin-config.xml");
+ generateReport(getGoal(), "default-configuration/cpd-javascript-plugin-config.xml");
// verify the generated file to exist and violations are reported
File generatedFile = new File(getBasedir(), "target/test/unit/default-configuration/target/cpd.xml");
@@ -221,7 +220,7 @@ public void testCpdJavascriptConfiguration() throws Exception {
}
public void testCpdJspConfiguration() throws Exception {
- generateReport("cpd", "default-configuration/cpd-jsp-plugin-config.xml");
+ generateReport(getGoal(), "default-configuration/cpd-jsp-plugin-config.xml");
// verify the generated file to exist and violations are reported
File generatedFile = new File(getBasedir(), "target/test/unit/default-configuration/target/cpd.xml");
@@ -232,7 +231,7 @@ public void testCpdJspConfiguration() throws Exception {
}
public void testExclusionsConfiguration() throws Exception {
- generateReport("cpd", "default-configuration/cpd-report-cpd-exclusions-configuration-plugin-config.xml");
+ generateReport(getGoal(), "default-configuration/cpd-report-cpd-exclusions-configuration-plugin-config.xml");
// verify the generated file to exist and no duplications are reported
File generatedFile = new File(getBasedir(), "target/test/unit/default-configuration/target/cpd.xml");
@@ -240,4 +239,9 @@ public void testExclusionsConfiguration() throws Exception {
String str = readFile(generatedFile);
assertEquals(0, StringUtils.countMatches(str, "UnusedPrivateField"));
// there should be the section Violations By Priority
- assertTrue(str.contains("Violations By Priority"));
- assertTrue(str.contains("Priority 3"));
- assertTrue(str.contains("Priority 4"));
+ assertTrue(str.contains("Violations By Priority"));
+ assertTrue(str.contains("Priority 3"));
+ assertTrue(str.contains("Priority 4"));
// the file App.java is mentioned 3 times: in prio 3, in prio 4 and in the files section
assertEquals(3, StringUtils.countMatches(str, "def/configuration/App.java"));
@@ -105,8 +104,8 @@ public void testDefaultConfigurationNotRenderRuleViolationPriority() throws Exce
new File(getBasedir(), "src/test/resources/unit/default-configuration/jxr-files"),
new File(getBasedir(), "target/test/unit/default-configuration/target/site"));
- File generatedReport =
- generateReport("pmd", "default-configuration/pmd-report-not-render-rule-priority-plugin-config.xml");
+ File generatedReport = generateReport(
+ getGoal(), "default-configuration/pmd-report-not-render-rule-priority-plugin-config.xml");
assertTrue(FileUtils.fileExists(generatedReport.getAbsolutePath()));
String str = readFile(generatedReport);
@@ -121,7 +120,7 @@ public void testDefaultConfigurationNoRenderViolationsByPriority() throws Except
new File(getBasedir(), "target/test/unit/default-configuration/target/site"));
File generatedReport =
- generateReport("pmd", "default-configuration/pmd-report-no-render-violations-by-priority.xml");
+ generateReport(getGoal(), "default-configuration/pmd-report-no-render-violations-by-priority.xml");
assertTrue(FileUtils.fileExists(generatedReport.getAbsolutePath()));
String str = readFile(generatedReport);
@@ -139,7 +138,7 @@ public void testDefaultConfigurationWithAnalysisCache() throws Exception {
new File(getBasedir(), "src/test/resources/unit/default-configuration/jxr-files"),
new File(getBasedir(), "target/test/unit/pmd-with-analysis-cache-plugin-config/target/site"));
- generateReport("pmd", "default-configuration/pmd-with-analysis-cache-plugin-config.xml");
+ generateReport(getGoal(), "default-configuration/pmd-with-analysis-cache-plugin-config.xml");
// check if the PMD analysis cache file has been generated
File cacheFile =
@@ -149,7 +148,7 @@ public void testDefaultConfigurationWithAnalysisCache() throws Exception {
public void testJavascriptConfiguration() throws Exception {
File generatedReport =
- generateReport("pmd", "default-configuration/javascript-configuration-plugin-config.xml");
+ generateReport(getGoal(), "default-configuration/javascript-configuration-plugin-config.xml");
assertTrue(FileUtils.fileExists(generatedReport.getAbsolutePath()));
// check if the PMD files were generated
@@ -180,7 +179,7 @@ public void testFileURL() throws Exception {
File testPom = new File(
getBasedir(), "src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml");
- PmdReport mojo = (PmdReport) createReportMojo("pmd", testPom);
+ PmdReport mojo = (PmdReport) createReportMojo(getGoal(), testPom);
// Additional test case for MPMD-174 (https://issues.apache.org/jira/browse/MPMD-174).
int port = determineFreePort();
@@ -270,7 +269,7 @@ private int determineFreePort() {
* @throws Exception
*/
public void testCustomConfiguration() throws Exception {
- File generatedReport = generateReport("pmd", "custom-configuration/custom-configuration-plugin-config.xml");
+ File generatedReport = generateReport(getGoal(), "custom-configuration/custom-configuration-plugin-config.xml");
assertTrue(FileUtils.fileExists(generatedReport.getAbsolutePath()));
// check the generated files
@@ -307,7 +306,7 @@ public void testCustomConfiguration() throws Exception {
* @throws Exception
*/
public void testSkipConfiguration() throws Exception {
- File generatedReport = generateReport("pmd", "custom-configuration/skip-plugin-config.xml");
+ File generatedReport = generateReport(getGoal(), "custom-configuration/skip-plugin-config.xml");
assertFalse(FileUtils.fileExists(generatedReport.getAbsolutePath()));
// verify the generated files do not exist because PMD was skipped
@@ -319,17 +318,17 @@ public void testSkipConfiguration() throws Exception {
// the fact, the PMD execution has been skipped, should be logged
String output = CapturingPrintStream.getOutput();
- assertTrue(output.contains("Skipping PMD execution"));
+ assertTrue(output.contains("Skipping org.apache.maven.plugins:maven-pmd-plugin"));
}
public void testSkipEmptyReportConfiguration() throws Exception {
// verify the generated files do not exist because PMD was skipped
- File generatedReport = generateReport("pmd", "empty-report/skip-empty-report-plugin-config.xml");
+ File generatedReport = generateReport(getGoal(), "empty-report/skip-empty-report-plugin-config.xml");
assertFalse(FileUtils.fileExists(generatedReport.getAbsolutePath()));
}
public void testEmptyReportConfiguration() throws Exception {
- File generatedReport = generateReport("pmd", "empty-report/empty-report-plugin-config.xml");
+ File generatedReport = generateReport(getGoal(), "empty-report/empty-report-plugin-config.xml");
assertTrue(FileUtils.fileExists(generatedReport.getAbsolutePath()));
// verify the generated files do exist, even if there are no violations
@@ -345,7 +344,7 @@ public void testInvalidFormat() throws Exception {
try {
File testPom =
new File(getBasedir(), "src/test/resources/unit/invalid-format/invalid-format-plugin-config.xml");
- AbstractPmdReport mojo = createReportMojo("pmd", testPom);
+ AbstractPmdReport mojo = createReportMojo(getGoal(), testPom);
setVariableValueToObject(
mojo, "compileSourceRoots", mojo.getProject().getCompileSourceRoots());
generateReport(mojo, testPom);
@@ -358,7 +357,7 @@ public void testInvalidFormat() throws Exception {
public void testInvalidTargetJdk() throws Exception {
try {
- generateReport("pmd", "empty-report/invalid-format/invalid-target-jdk-plugin-config.xml");
+ generateReport(getGoal(), "empty-report/invalid-format/invalid-target-jdk-plugin-config.xml");
fail("Must throw MavenReportException.");
} catch (Exception e) {
@@ -367,12 +366,12 @@ public void testInvalidTargetJdk() throws Exception {
}
/**
- * verify the pmd.xml file is included in the site when requested.
+ * verify the pmd.xml file is included in the reports when requested.
* @throws Exception
*/
- public void testIncludeXmlInSite() throws Exception {
+ public void testIncludeXmlInReports() throws Exception {
File generatedReport =
- generateReport("pmd", "default-configuration/pmd-report-include-xml-in-site-plugin-config.xml");
+ generateReport(getGoal(), "default-configuration/pmd-report-include-xml-in-reports-config.xml");
assertTrue(FileUtils.fileExists(generatedReport.getAbsolutePath()));
// verify the pmd file is included in site
@@ -396,7 +395,7 @@ public void testLocationTemp() throws Exception {
File testPom = new File(
getBasedir(), "src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml");
- PmdReport mojo = (PmdReport) lookupMojo("pmd", testPom);
+ PmdReport mojo = (PmdReport) lookupMojo(getGoal(), testPom);
assertEquals(
"locationTemp is not correctly encoding filename",
@@ -412,7 +411,8 @@ public void testLocationTemp() throws Exception {
* @throws Exception
*/
public void testSuppressMarkerConfiguration() throws Exception {
- File generatedReport = generateReport("pmd", "default-configuration/pmd-with-suppressMarker-plugin-config.xml");
+ File generatedReport =
+ generateReport(getGoal(), "default-configuration/pmd-with-suppressMarker-plugin-config.xml");
assertTrue(FileUtils.fileExists(generatedReport.getAbsolutePath()));
// check if the PMD files were generated
@@ -437,7 +437,7 @@ public void testSuppressMarkerConfiguration() throws Exception {
public void testSuppressMarkerConfigurationWithoutRendering() throws Exception {
File generatedReport =
- generateReport("pmd", "default-configuration/pmd-with-suppressMarker-no-render-plugin-config.xml");
+ generateReport(getGoal(), "default-configuration/pmd-with-suppressMarker-no-render-plugin-config.xml");
assertTrue(FileUtils.fileExists(generatedReport.getAbsolutePath()));
// check if the PMD files were generated
@@ -461,7 +461,7 @@ public void testSuppressMarkerConfigurationWithoutRendering() throws Exception {
}
public void testJspConfiguration() throws Exception {
- File generatedReport = generateReport("pmd", "default-configuration/jsp-configuration-plugin-config.xml");
+ File generatedReport = generateReport(getGoal(), "default-configuration/jsp-configuration-plugin-config.xml");
assertTrue(FileUtils.fileExists(generatedReport.getAbsolutePath()));
// check if the PMD files were generated
@@ -497,15 +497,16 @@ public void testJspConfiguration() throws Exception {
public void testPMDProcessingError() throws Exception {
try {
- generateReport("pmd", "processing-error/pmd-processing-error-plugin-config.xml");
+ generateReport(getGoal(), "processing-error/pmd-processing-error-plugin-config.xml");
fail("Expected exception");
- } catch (RuntimeException e) {
- assertTrue(e.getMessage().endsWith("Found 1 PMD processing errors"));
+ } catch (MojoExecutionException e) {
+ assertTrue(e.getCause().getMessage().endsWith("Found 1 PMD processing errors"));
}
}
public void testPMDProcessingErrorWithDetailsSkipped() throws Exception {
- File generatedReport = generateReport("pmd", "processing-error/pmd-processing-error-skip-plugin-config.xml");
+ File generatedReport =
+ generateReport(getGoal(), "processing-error/pmd-processing-error-skip-plugin-config.xml");
assertTrue(FileUtils.fileExists(generatedReport.getAbsolutePath()));
String output = CapturingPrintStream.getOutput();
@@ -526,7 +527,7 @@ public void testPMDProcessingErrorWithDetailsSkipped() throws Exception {
public void testPMDProcessingErrorWithDetailsNoReport() throws Exception {
File generatedReport =
- generateReport("pmd", "processing-error/pmd-processing-error-no-report-plugin-config.xml");
+ generateReport(getGoal(), "processing-error/pmd-processing-error-no-report-plugin-config.xml");
assertTrue(FileUtils.fileExists(generatedReport.getAbsolutePath()));
String output = CapturingPrintStream.getOutput();
@@ -546,7 +547,7 @@ public void testPMDProcessingErrorWithDetailsNoReport() throws Exception {
}
public void testPMDExcludeRootsShouldExcludeSubdirectories() throws Exception {
- generateReport("pmd", "exclude-roots/pmd-exclude-roots-plugin-config.xml");
+ generateReport(getGoal(), "exclude-roots/pmd-exclude-roots-plugin-config.xml");
File generatedFile = new File(getBasedir(), "target/test/unit/exclude-roots/target/pmd.xml");
assertTrue(FileUtils.fileExists(generatedFile.getAbsolutePath()));
@@ -561,7 +562,7 @@ public void testPMDExcludeRootsShouldExcludeSubdirectories() throws Exception {
}
public void testViolationExclusion() throws Exception {
- generateReport("pmd", "default-configuration/pmd-report-pmd-exclusions-configuration-plugin-config.xml");
+ generateReport(getGoal(), "default-configuration/pmd-report-pmd-exclusions-configuration-plugin-config.xml");
File generatedFile = new File(getBasedir(), "target/test/unit/default-configuration/target/pmd.xml");
assertTrue(FileUtils.fileExists(generatedFile.getAbsolutePath()));
@@ -586,13 +587,13 @@ public void testPmdReportCustomRulesNoExternalInfoUrl() throws Exception {
new File(getBasedir(), "src/test/resources/unit/default-configuration/jxr-files"),
new File(getBasedir(), "target/test/unit/default-configuration/target/site"));
- File generatedReport = generateReport("pmd", "default-configuration/pmd-report-custom-rules.xml");
+ File generatedReport = generateReport(getGoal(), "default-configuration/pmd-report-custom-rules.xml");
assertTrue(FileUtils.fileExists(generatedReport.getAbsolutePath()));
String str = readFile(generatedReport);
// custom rule without link
- assertEquals(2, StringUtils.countMatches(str, "CustomRule | "));
+ assertEquals(2, StringUtils.countMatches(str, "CustomRule | "));
// standard rule with link
assertEquals(4, StringUtils.countMatches(str, "\">UnusedPrivateField"));
}
@@ -639,7 +640,7 @@ public void testPmdReportResolveRulesets() throws Exception {
File testPom =
new File(getBasedir(), "src/test/resources/unit/default-configuration/pmd-report-resolve-rulesets.xml");
- PmdReport mojo = (PmdReport) createReportMojo("pmd", testPom);
+ PmdReport mojo = (PmdReport) createReportMojo(getGoal(), testPom);
mojo.rulesets[3] = sonarExportRulesetUrl;
mojo.rulesets[4] = myRulesetUrl;
mojo.rulesets[5] = notAInternalRulesetUrl;
@@ -674,4 +675,9 @@ public void testPmdReportResolveRulesets() throws Exception {
mockServer.stop();
}
+
+ @Override
+ protected String getGoal() {
+ return "pmd";
+ }
}
diff --git a/src/test/java/org/apache/maven/plugins/pmd/PmdViolationCheckMojoTest.java b/src/test/java/org/apache/maven/plugins/pmd/PmdViolationCheckMojoTest.java
index b47508b8..01d10df0 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/PmdViolationCheckMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/PmdViolationCheckMojoTest.java
@@ -38,7 +38,7 @@ public void testDefaultConfiguration() throws Exception {
final File testPom = new File(
getBasedir(),
"src/test/resources/unit/default-configuration/pmd-check-default-configuration-plugin-config.xml");
- final PmdViolationCheckMojo mojo = (PmdViolationCheckMojo) lookupMojo("check", testPom);
+ final PmdViolationCheckMojo mojo = (PmdViolationCheckMojo) lookupMojo(getGoal(), testPom);
mojo.execute();
fail("MojoFailureException should be thrown.");
@@ -57,7 +57,7 @@ public void testNotFailOnViolation() throws Exception {
File testPom = new File(
getBasedir(),
"src/test/resources/unit/default-configuration/pmd-check-notfailonviolation-plugin-config.xml");
- final PmdViolationCheckMojo pmdViolationMojo = (PmdViolationCheckMojo) lookupMojo("check", testPom);
+ final PmdViolationCheckMojo pmdViolationMojo = (PmdViolationCheckMojo) lookupMojo(getGoal(), testPom);
pmdViolationMojo.execute();
assertTrue(true);
@@ -69,13 +69,13 @@ public void testMaxAllowedViolations() throws Exception {
File testPom = new File(
getBasedir(),
"src/test/resources/unit/default-configuration/pmd-check-notfailmaxviolation-plugin-config.xml");
- final PmdViolationCheckMojo pmdViolationMojo = (PmdViolationCheckMojo) lookupMojo("check", testPom);
+ final PmdViolationCheckMojo pmdViolationMojo = (PmdViolationCheckMojo) lookupMojo(getGoal(), testPom);
pmdViolationMojo.execute();
testPom = new File(
getBasedir(),
"src/test/resources/unit/default-configuration/pmd-check-failmaxviolation-plugin-config.xml");
- final PmdViolationCheckMojo pmdViolationMojoFail = (PmdViolationCheckMojo) lookupMojo("check", testPom);
+ final PmdViolationCheckMojo pmdViolationMojoFail = (PmdViolationCheckMojo) lookupMojo(getGoal(), testPom);
try {
pmdViolationMojoFail.execute();
@@ -97,13 +97,13 @@ public void testFailurePriority() throws Exception {
File testPom = new File(
getBasedir(),
"src/test/resources/unit/default-configuration/pmd-check-failonpriority-plugin-config.xml");
- PmdViolationCheckMojo pmdViolationMojo = (PmdViolationCheckMojo) lookupMojo("check", testPom);
+ PmdViolationCheckMojo pmdViolationMojo = (PmdViolationCheckMojo) lookupMojo(getGoal(), testPom);
pmdViolationMojo.execute();
testPom = new File(
getBasedir(),
"src/test/resources/unit/default-configuration/pmd-check-failandwarnonpriority-plugin-config.xml");
- pmdViolationMojo = (PmdViolationCheckMojo) lookupMojo("check", testPom);
+ pmdViolationMojo = (PmdViolationCheckMojo) lookupMojo(getGoal(), testPom);
try {
pmdViolationMojo.execute();
fail("Exception Expected");
@@ -123,7 +123,7 @@ public void testException() throws Exception {
final File testPom = new File(
getBasedir(),
"src/test/resources/unit/custom-configuration/pmd-check-exception-test-plugin-config.xml");
- final PmdViolationCheckMojo mojo = (PmdViolationCheckMojo) lookupMojo("check", testPom);
+ final PmdViolationCheckMojo mojo = (PmdViolationCheckMojo) lookupMojo(getGoal(), testPom);
mojo.execute();
fail("MojoFailureException should be thrown.");
@@ -138,9 +138,14 @@ public void testViolationExclusion() throws Exception {
File testPom = new File(
getBasedir(),
"src/test/resources/unit/default-configuration/pmd-check-pmd-exclusions-configuration-plugin-config.xml");
- final PmdViolationCheckMojo pmdViolationMojo = (PmdViolationCheckMojo) lookupMojo("check", testPom);
+ final PmdViolationCheckMojo pmdViolationMojo = (PmdViolationCheckMojo) lookupMojo(getGoal(), testPom);
// this call shouldn't throw an exception, as the classes with violations have been excluded
pmdViolationMojo.execute();
}
+
+ @Override
+ protected String getGoal() {
+ return "check";
+ }
}
diff --git a/src/test/java/org/apache/maven/plugins/pmd/stubs/CustomConfigurationMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/pmd/stubs/CustomConfigurationMavenProjectStub.java
index 1d892b7f..1d79c445 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/stubs/CustomConfigurationMavenProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/stubs/CustomConfigurationMavenProjectStub.java
@@ -44,8 +44,7 @@ public CustomConfigurationMavenProjectStub() {
MavenXpp3Reader pomReader = new MavenXpp3Reader();
Model model = null;
- try (InputStream is = new FileInputStream(new File(getBasedir()
- + "/src/test/resources/unit/custom-configuration/custom-configuration-plugin-config.xml"))) {
+ try (InputStream is = new FileInputStream(new File(getBasedir() + "/" + getPOM()))) {
model = pomReader.read(is);
setModel(model);
} catch (Exception e) {
@@ -64,15 +63,15 @@ public CustomConfigurationMavenProjectStub() {
Build build = new Build();
build.setFinalName(model.getBuild().getFinalName());
- build.setDirectory(getBasedir() + "/target/test/unit/custom-configuration/target");
- build.setSourceDirectory(getBasedir() + "/src/test/resources/unit/custom-configuration");
+ build.setDirectory(getBasedir() + "/target");
+ build.setSourceDirectory(getBasedir().getAbsolutePath());
setBuild(build);
setReportPlugins(model.getReporting().getPlugins());
String basedir = getBasedir().getAbsolutePath();
List compileSourceRoots = new ArrayList<>();
- compileSourceRoots.add(basedir + "/src/test/resources/unit/custom-configuration/custom/configuration");
+ compileSourceRoots.add(basedir + "/custom/configuration");
setCompileSourceRoots(compileSourceRoots);
Artifact artifact = new PmdPluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging());
@@ -103,4 +102,14 @@ public void setReportPlugins(List plugins) {
public List getReportPlugins() {
return reportPlugins;
}
+
+ @Override
+ public File getBasedir() {
+ return new File(super.getBasedir() + "/custom-configuration");
+ }
+
+ @Override
+ protected String getPOM() {
+ return "custom-configuration-plugin-config.xml";
+ }
}
diff --git a/src/test/java/org/apache/maven/plugins/pmd/stubs/DefaultConfigurationMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/pmd/stubs/DefaultConfigurationMavenProjectStub.java
index e02a9a8b..ba1bc727 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/stubs/DefaultConfigurationMavenProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/stubs/DefaultConfigurationMavenProjectStub.java
@@ -44,8 +44,7 @@ public DefaultConfigurationMavenProjectStub() {
MavenXpp3Reader pomReader = new MavenXpp3Reader();
Model model = null;
- try (InputStream is = new FileInputStream(new File(getBasedir()
- + "/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml"))) {
+ try (InputStream is = new FileInputStream(new File(getBasedir() + "/" + getPOM()))) {
model = pomReader.read(is);
setModel(model);
} catch (Exception e) {
@@ -64,15 +63,15 @@ public DefaultConfigurationMavenProjectStub() {
Build build = new Build();
build.setFinalName(model.getBuild().getFinalName());
- build.setDirectory(getBasedir() + "/target/test/unit/default-configuration/target");
- build.setSourceDirectory(getBasedir() + "/src/test/resources/unit/default-configuration");
+ build.setDirectory(getBasedir() + "/target");
+ build.setSourceDirectory(getBasedir().getAbsolutePath());
setBuild(build);
setReportPlugins(model.getReporting().getPlugins());
String basedir = getBasedir().getAbsolutePath();
List compileSourceRoots = new ArrayList<>();
- compileSourceRoots.add(basedir + "/src/test/resources/unit/default-configuration/def/configuration");
+ compileSourceRoots.add(basedir + "/def/configuration");
setCompileSourceRoots(compileSourceRoots);
File file = new File(getBasedir().getAbsolutePath() + "/pom.xml");
@@ -104,4 +103,14 @@ public void setBuild(Build build) {
public Build getBuild() {
return build;
}
+
+ @Override
+ public File getBasedir() {
+ return new File(super.getBasedir() + "/default-configuration");
+ }
+
+ @Override
+ protected String getPOM() {
+ return "default-configuration-plugin-config.xml";
+ }
}
diff --git a/src/test/java/org/apache/maven/plugins/pmd/stubs/InvalidFormatMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/pmd/stubs/InvalidFormatMavenProjectStub.java
index 6e0a86dd..381fff93 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/stubs/InvalidFormatMavenProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/stubs/InvalidFormatMavenProjectStub.java
@@ -41,8 +41,7 @@ public InvalidFormatMavenProjectStub() {
MavenXpp3Reader pomReader = new MavenXpp3Reader();
Model model = null;
- try (InputStream is = new FileInputStream(
- new File(getBasedir() + "/src/test/resources/unit/invalid-format/invalid-format-plugin-config.xml"))) {
+ try (InputStream is = new FileInputStream(new File(getBasedir() + "/" + getPOM()))) {
model = pomReader.read(is);
setModel(model);
} catch (Exception e) {
@@ -61,13 +60,13 @@ public InvalidFormatMavenProjectStub() {
Build build = new Build();
build.setFinalName(model.getBuild().getFinalName());
- build.setDirectory(getBasedir() + "/target/test/unit/invalid-format/target");
- build.setSourceDirectory(getBasedir() + "/src/test/resources/unit/invalid-format");
+ build.setDirectory(getBasedir() + "/target");
+ build.setSourceDirectory(getBasedir().getAbsolutePath());
setBuild(build);
String basedir = getBasedir().getAbsolutePath();
List compileSourceRoots = new ArrayList<>();
- compileSourceRoots.add(basedir + "/src/test/resources/unit/invalid-format/invalid/format");
+ compileSourceRoots.add(basedir + "/invalid/format");
setCompileSourceRoots(compileSourceRoots);
Artifact artifact = new PmdPluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging());
@@ -88,4 +87,14 @@ public void setBuild(Build build) {
public Build getBuild() {
return build;
}
+
+ @Override
+ public File getBasedir() {
+ return new File(super.getBasedir() + "/invalid-format");
+ }
+
+ @Override
+ protected String getPOM() {
+ return "invalid-format-plugin-config.xml";
+ }
}
diff --git a/src/test/java/org/apache/maven/plugins/pmd/stubs/PmdProjectStub.java b/src/test/java/org/apache/maven/plugins/pmd/stubs/PmdProjectStub.java
index fd34c4f6..1a0d86f1 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/stubs/PmdProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/stubs/PmdProjectStub.java
@@ -18,16 +18,34 @@
*/
package org.apache.maven.plugins.pmd.stubs;
+import java.io.File;
import java.util.Collections;
import java.util.List;
+import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.artifact.repository.MavenArtifactRepository;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.eclipse.aether.repository.RemoteRepository;
public abstract class PmdProjectStub extends MavenProjectStub {
+ /**
+ * @return the POM file name
+ */
+ protected abstract String getPOM();
+
+ @Override
+ public File getBasedir() {
+ return new File(super.getBasedir() + "/src/test/resources/unit/");
+ }
+
+ @Override
+ public File getFile() {
+ return new File(getBasedir(), getPOM());
+ }
+
@Override
public List getRemoteArtifactRepositories() {
ArtifactRepository repository = new MavenArtifactRepository(
@@ -39,4 +57,9 @@ public List getRemoteArtifactRepositories() {
return Collections.singletonList(repository);
}
+
+ @Override
+ public List getRemoteProjectRepositories() {
+ return RepositoryUtils.toRepos(getRemoteArtifactRepositories());
+ }
}
diff --git a/src/test/resources/unit/custom-configuration/cpd-custom-configuration-plugin-config.xml b/src/test/resources/unit/custom-configuration/cpd-custom-configuration-plugin-config.xml
index 35955898..6fd8a79e 100644
--- a/src/test/resources/unit/custom-configuration/cpd-custom-configuration-plugin-config.xml
+++ b/src/test/resources/unit/custom-configuration/cpd-custom-configuration-plugin-config.xml
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/custom-configuration/target/site
${basedir}/target/test/unit/custom-configuration/target
- ${localRepository}
csv
false
${basedir}/target/test/unit/custom-configuration/target/site/xref
diff --git a/src/test/resources/unit/custom-configuration/cpd-txt-format-configuration-plugin-config.xml b/src/test/resources/unit/custom-configuration/cpd-txt-format-configuration-plugin-config.xml
index eb7d1fe3..ffc29032 100644
--- a/src/test/resources/unit/custom-configuration/cpd-txt-format-configuration-plugin-config.xml
+++ b/src/test/resources/unit/custom-configuration/cpd-txt-format-configuration-plugin-config.xml
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/custom-configuration/target/site
${basedir}/target/test/unit/custom-configuration/target
- ${localRepository}
txt
false
30
diff --git a/src/test/resources/unit/custom-configuration/custom-configuration-plugin-config.xml b/src/test/resources/unit/custom-configuration/custom-configuration-plugin-config.xml
index 8cfd6ef5..d1ff3f43 100644
--- a/src/test/resources/unit/custom-configuration/custom-configuration-plugin-config.xml
+++ b/src/test/resources/unit/custom-configuration/custom-configuration-plugin-config.xml
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/custom-configuration/target/site
${basedir}/target/test/unit/custom-configuration/target
- ${localRepository}
${basedir}/target/test/unit/custom-configuration/target/pmd/rulesets
csv
true
diff --git a/src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml b/src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml
index e57fe5d3..a201c3ee 100644
--- a/src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
- ${localRepository}
xml
false
${basedir}/target/test/unit/default-configuration/target/site/xref
diff --git a/src/test/resources/unit/default-configuration/cpd-javascript-plugin-config.xml b/src/test/resources/unit/default-configuration/cpd-javascript-plugin-config.xml
index f7e045ad..089fb484 100644
--- a/src/test/resources/unit/default-configuration/cpd-javascript-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/cpd-javascript-plugin-config.xml
@@ -35,7 +35,6 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
- ${localRepository}
xml
false
${basedir}/target/test/unit/default-configuration/target/site/xref
diff --git a/src/test/resources/unit/default-configuration/cpd-jsp-plugin-config.xml b/src/test/resources/unit/default-configuration/cpd-jsp-plugin-config.xml
index 6ad62d0b..3cb44b30 100644
--- a/src/test/resources/unit/default-configuration/cpd-jsp-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/cpd-jsp-plugin-config.xml
@@ -35,7 +35,6 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
- ${localRepository}
xml
false
${basedir}/target/test/unit/default-configuration/target/site/xref
diff --git a/src/test/resources/unit/default-configuration/cpd-report-cpd-exclusions-configuration-plugin-config.xml b/src/test/resources/unit/default-configuration/cpd-report-cpd-exclusions-configuration-plugin-config.xml
index 85ea1918..76efc020 100644
--- a/src/test/resources/unit/default-configuration/cpd-report-cpd-exclusions-configuration-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/cpd-report-cpd-exclusions-configuration-plugin-config.xml
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
- ${localRepository}
xml
false
${basedir}/target/test/unit/default-configuration/target/site/xref
diff --git a/src/test/resources/unit/default-configuration/cpd-report-include-xml-in-site-plugin-config.xml b/src/test/resources/unit/default-configuration/cpd-report-include-xml-in-reports-config.xml
similarity index 94%
rename from src/test/resources/unit/default-configuration/cpd-report-include-xml-in-site-plugin-config.xml
rename to src/test/resources/unit/default-configuration/cpd-report-include-xml-in-reports-config.xml
index 7920f0a4..afe562b1 100644
--- a/src/test/resources/unit/default-configuration/cpd-report-include-xml-in-site-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/cpd-report-include-xml-in-reports-config.xml
@@ -24,7 +24,7 @@ under the License.
jar
1.0-SNAPSHOT
2006
- Maven CPD Plugin Default Configuration Test With includeXmlInSite
+ Maven CPD Plugin Default Configuration Test With includeXmlInReports
http://maven.apache.org
default-configuration
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
- ${localRepository}
xml
false
${basedir}/target/test/unit/default-configuration/target/site/xref
@@ -45,7 +44,7 @@ under the License.
${basedir}/src/test/resources/unit/default-configuration/
UTF-8
- true
+ true
xml
diff --git a/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml b/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml
index 36e22ec5..fb99dbf1 100644
--- a/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
- ${localRepository}
${basedir}/target/test/unit/default-configuration/target/pmd/rulesets
xml
true
diff --git a/src/test/resources/unit/default-configuration/javascript-configuration-plugin-config.xml b/src/test/resources/unit/default-configuration/javascript-configuration-plugin-config.xml
index 24457540..791540f1 100644
--- a/src/test/resources/unit/default-configuration/javascript-configuration-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/javascript-configuration-plugin-config.xml
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
- ${localRepository}
${basedir}/target/test/unit/default-configuration/target/pmd/rulesets
xml
UTF-8
diff --git a/src/test/resources/unit/default-configuration/jsp-configuration-plugin-config.xml b/src/test/resources/unit/default-configuration/jsp-configuration-plugin-config.xml
index 0de51597..a0fa7f44 100644
--- a/src/test/resources/unit/default-configuration/jsp-configuration-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/jsp-configuration-plugin-config.xml
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
- ${localRepository}
${basedir}/target/test/unit/default-configuration/target/pmd/rulesets
xml
UTF-8
diff --git a/src/test/resources/unit/default-configuration/pmd-report-custom-rules.xml b/src/test/resources/unit/default-configuration/pmd-report-custom-rules.xml
index b5f9c4dd..c737e21c 100644
--- a/src/test/resources/unit/default-configuration/pmd-report-custom-rules.xml
+++ b/src/test/resources/unit/default-configuration/pmd-report-custom-rules.xml
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
- ${localRepository}
${basedir}/target/test/unit/default-configuration/target/pmd/rulesets
${basedir}/src/test/resources/unit/default-configuration/rulesets/custom-rules.xml
diff --git a/src/test/resources/unit/default-configuration/pmd-report-include-xml-in-site-plugin-config.xml b/src/test/resources/unit/default-configuration/pmd-report-include-xml-in-reports-config.xml
similarity index 95%
rename from src/test/resources/unit/default-configuration/pmd-report-include-xml-in-site-plugin-config.xml
rename to src/test/resources/unit/default-configuration/pmd-report-include-xml-in-reports-config.xml
index e62b70ce..88e269bf 100644
--- a/src/test/resources/unit/default-configuration/pmd-report-include-xml-in-site-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/pmd-report-include-xml-in-reports-config.xml
@@ -36,11 +36,10 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
- ${localRepository}
${basedir}/target/test/unit/default-configuration/target/pmd/rulesets
xml
UTF-8
- true
+ true
diff --git a/src/test/resources/unit/default-configuration/pmd-report-no-render-violations-by-priority.xml b/src/test/resources/unit/default-configuration/pmd-report-no-render-violations-by-priority.xml
index a9db808a..9194f6f9 100644
--- a/src/test/resources/unit/default-configuration/pmd-report-no-render-violations-by-priority.xml
+++ b/src/test/resources/unit/default-configuration/pmd-report-no-render-violations-by-priority.xml
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
- ${localRepository}
${basedir}/target/test/unit/default-configuration/target/pmd/rulesets
xml
true
diff --git a/src/test/resources/unit/default-configuration/pmd-report-not-render-rule-priority-plugin-config.xml b/src/test/resources/unit/default-configuration/pmd-report-not-render-rule-priority-plugin-config.xml
index f2633ce2..572a5e1e 100644
--- a/src/test/resources/unit/default-configuration/pmd-report-not-render-rule-priority-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/pmd-report-not-render-rule-priority-plugin-config.xml
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
- ${localRepository}
${basedir}/target/test/unit/default-configuration/target/pmd/rulesets
xml
true
diff --git a/src/test/resources/unit/default-configuration/pmd-report-pmd-exclusions-configuration-plugin-config.xml b/src/test/resources/unit/default-configuration/pmd-report-pmd-exclusions-configuration-plugin-config.xml
index 246d4952..3387d3ed 100644
--- a/src/test/resources/unit/default-configuration/pmd-report-pmd-exclusions-configuration-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/pmd-report-pmd-exclusions-configuration-plugin-config.xml
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
- ${localRepository}
${basedir}/target/test/unit/default-configuration/target/pmd/rulesets
xml
true
diff --git a/src/test/resources/unit/default-configuration/pmd-report-resolve-rulesets.xml b/src/test/resources/unit/default-configuration/pmd-report-resolve-rulesets.xml
index ba37dd30..b03474bb 100644
--- a/src/test/resources/unit/default-configuration/pmd-report-resolve-rulesets.xml
+++ b/src/test/resources/unit/default-configuration/pmd-report-resolve-rulesets.xml
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
- ${localRepository}
${basedir}/target/test/unit/default-configuration/target/pmd/rulesets
${basedir}/src/test/resources/unit/default-configuration/rulesets/custom-rules.xml
diff --git a/src/test/resources/unit/default-configuration/pmd-with-analysis-cache-plugin-config.xml b/src/test/resources/unit/default-configuration/pmd-with-analysis-cache-plugin-config.xml
index df2c0f19..642f124e 100644
--- a/src/test/resources/unit/default-configuration/pmd-with-analysis-cache-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/pmd-with-analysis-cache-plugin-config.xml
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/pmd-with-analysis-cache-plugin-config/target/site
${basedir}/target/test/unit/pmd-with-analysis-cache-plugin-config/target
- ${localRepository}
${basedir}/target/test/unit/pmd-with-analysis-cache-plugin-config/target/pmd/rulesets
xml
true
diff --git a/src/test/resources/unit/default-configuration/pmd-with-suppressMarker-no-render-plugin-config.xml b/src/test/resources/unit/default-configuration/pmd-with-suppressMarker-no-render-plugin-config.xml
index 9ed62576..d3889696 100644
--- a/src/test/resources/unit/default-configuration/pmd-with-suppressMarker-no-render-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/pmd-with-suppressMarker-no-render-plugin-config.xml
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
- ${localRepository}
${basedir}/target/test/unit/default-configuration/target/pmd/rulesets
xml
true
diff --git a/src/test/resources/unit/default-configuration/pmd-with-suppressMarker-plugin-config.xml b/src/test/resources/unit/default-configuration/pmd-with-suppressMarker-plugin-config.xml
index c5116dd9..efd85233 100644
--- a/src/test/resources/unit/default-configuration/pmd-with-suppressMarker-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/pmd-with-suppressMarker-plugin-config.xml
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
- ${localRepository}
${basedir}/target/test/unit/default-configuration/target/pmd/rulesets
xml
true
diff --git a/src/test/resources/unit/empty-report/cpd-empty-report-plugin-config.xml b/src/test/resources/unit/empty-report/cpd-empty-report-plugin-config.xml
index be2b5348..e0001ecb 100644
--- a/src/test/resources/unit/empty-report/cpd-empty-report-plugin-config.xml
+++ b/src/test/resources/unit/empty-report/cpd-empty-report-plugin-config.xml
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/empty-report/target/site
${basedir}/target/test/unit/empty-report/target
- ${localRepository}
${basedir}/src/test/resources/unit/empty-report/java/
diff --git a/src/test/resources/unit/empty-report/empty-report-plugin-config.xml b/src/test/resources/unit/empty-report/empty-report-plugin-config.xml
index c1c6ea8e..00c24f08 100644
--- a/src/test/resources/unit/empty-report/empty-report-plugin-config.xml
+++ b/src/test/resources/unit/empty-report/empty-report-plugin-config.xml
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/empty-report/target/site
${basedir}/target/test/unit/empty-report/target
- ${localRepository}
${basedir}/target/test/unit/empty-report/target/pmd/rulesets
${basedir}/src/test/resources/unit/empty-report/java/
diff --git a/src/test/resources/unit/exclude-roots/pmd-exclude-roots-plugin-config.xml b/src/test/resources/unit/exclude-roots/pmd-exclude-roots-plugin-config.xml
index ac800c73..bec142fe 100644
--- a/src/test/resources/unit/exclude-roots/pmd-exclude-roots-plugin-config.xml
+++ b/src/test/resources/unit/exclude-roots/pmd-exclude-roots-plugin-config.xml
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/exclude-roots/target/site
${basedir}/target/test/unit/exclude-roots/target
- ${localRepository}
${basedir}/target/test/unit/exclude-roots/target/pmd/rulesets
xml
UTF-8
diff --git a/src/test/resources/unit/invalid-format/cpd-invalid-format-plugin-config.xml b/src/test/resources/unit/invalid-format/cpd-invalid-format-plugin-config.xml
index aca6d08e..e3cff6c2 100644
--- a/src/test/resources/unit/invalid-format/cpd-invalid-format-plugin-config.xml
+++ b/src/test/resources/unit/invalid-format/cpd-invalid-format-plugin-config.xml
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/invalid-format/target/site
${basedir}/target/test/unit/invalid-format/target
- ${localRepository}
xhtml
false
${basedir}/target/test/unit/invalid-format/target/site/xref
diff --git a/src/test/resources/unit/processing-error/pmd-processing-error-no-report-plugin-config.xml b/src/test/resources/unit/processing-error/pmd-processing-error-no-report-plugin-config.xml
index ba7f86f9..40f087f2 100644
--- a/src/test/resources/unit/processing-error/pmd-processing-error-no-report-plugin-config.xml
+++ b/src/test/resources/unit/processing-error/pmd-processing-error-no-report-plugin-config.xml
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/parse-error/target/site
${basedir}/target/test/unit/parse-error/target
- ${localRepository}
${basedir}/target/test/unit/parse-error/target/pmd/rulesets
xml
UTF-8
diff --git a/src/test/resources/unit/processing-error/pmd-processing-error-skip-plugin-config.xml b/src/test/resources/unit/processing-error/pmd-processing-error-skip-plugin-config.xml
index 686d7052..55c8a4d9 100644
--- a/src/test/resources/unit/processing-error/pmd-processing-error-skip-plugin-config.xml
+++ b/src/test/resources/unit/processing-error/pmd-processing-error-skip-plugin-config.xml
@@ -36,7 +36,6 @@ under the License.
${basedir}/target/test/unit/parse-error/target/site
${basedir}/target/test/unit/parse-error/target
- ${localRepository}
${basedir}/target/test/unit/parse-error/target/pmd/rulesets
xml
UTF-8