From e99d2e45eee345bf4a303645b5d39277597e37bc Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sat, 19 Oct 2024 22:01:45 +0200 Subject: [PATCH] [MPMD-407] Upgrade to Doxia 2.0.0 GA Stack This closes #175 --- pom.xml | 6 +-- .../maven/plugins/pmd/AbstractPmdReport.java | 54 +++---------------- 2 files changed, 9 insertions(+), 51 deletions(-) diff --git a/pom.xml b/pom.xml index a56a0f9a..832ed24e 100644 --- a/pom.xml +++ b/pom.xml @@ -86,11 +86,11 @@ under the License. 7.3.0 1.7.36 1.4.1 - 2.0.0-M12 + 2.0.0 3.11.0 3.20.0 3.7.0 - 3.4.0 + 3.5.0 2024-08-22T16:42:52Z @@ -212,7 +212,7 @@ under the License. org.apache.maven.reporting maven-reporting-impl - 4.0.0-M15 + 4.0.0 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 2fab8485..fbf21591 100644 --- a/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java +++ b/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java @@ -37,8 +37,6 @@ import net.sourceforge.pmd.PMDVersion; 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; @@ -48,7 +46,6 @@ import org.apache.maven.toolchain.Toolchain; import org.apache.maven.toolchain.ToolchainManager; import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.PathTool; import org.codehaus.plexus.util.StringUtils; /** @@ -283,45 +280,6 @@ protected MojoExecution getMojoExecution() { return mojoExecution; } - protected String constructXrefLocation(boolean test) { - String location = null; - if (linkXRef) { - File xrefLocation = getXrefLocation(test); - - String relativePath = PathTool.getRelativePath( - getReportOutputDirectory().getAbsolutePath(), xrefLocation.getAbsolutePath()); - if (relativePath == null || relativePath.isEmpty()) { - relativePath = "."; - } - relativePath = relativePath + "/" + xrefLocation.getName(); - if (xrefLocation.exists()) { - // XRef was already generated by manual execution of a lifecycle binding - location = relativePath; - } else { - // Not yet generated - check if the report is on its way - Reporting reporting = project.getModel().getReporting(); - List reportPlugins = - reporting != null ? reporting.getPlugins() : Collections.emptyList(); - for (ReportPlugin plugin : reportPlugins) { - String artifactId = plugin.getArtifactId(); - if ("maven-jxr-plugin".equals(artifactId)) { - location = relativePath; - } - } - } - - if (location == null) { - getLog().warn("Unable to locate" + (test ? " Test" : "") + " Source XRef to link to - DISABLED"); - } - } - return location; - } - - protected File getXrefLocation(boolean test) { - File location = test ? xrefTestLocation : xrefLocation; - return location != null ? location : new File(getReportOutputDirectory(), test ? "xref-test" : "xref"); - } - /** * Convenience method to get the list of files where the PMD tool will be executed * @@ -355,7 +313,7 @@ protected Map getFilesToProcess() throws IOException { for (String root : compileSourceRoots) { File sroot = new File(root); if (sroot.exists()) { - String sourceXref = constructXrefLocation(false); + String sourceXref = linkXRef ? constructXrefLocation(xrefLocation, false) : null; directories.add(new PmdFileInfo(project, sroot, sourceXref)); } } @@ -368,8 +326,8 @@ protected Map getFilesToProcess() throws IOException { for (String root : testSourceRoots) { File sroot = new File(root); if (sroot.exists()) { - String testXref = constructXrefLocation(true); - directories.add(new PmdFileInfo(project, sroot, testXref)); + String testSourceXref = linkXRef ? constructXrefLocation(xrefTestLocation, true) : null; + directories.add(new PmdFileInfo(project, sroot, testSourceXref)); } } } @@ -379,7 +337,7 @@ protected Map getFilesToProcess() throws IOException { for (String root : localCompileSourceRoots) { File sroot = new File(root); if (sroot.exists()) { - String sourceXref = constructXrefLocation(false); + String sourceXref = linkXRef ? constructXrefLocation(xrefLocation, false) : null; directories.add(new PmdFileInfo(localProject, sroot, sourceXref)); } } @@ -388,8 +346,8 @@ protected Map getFilesToProcess() throws IOException { for (String root : localTestCompileSourceRoots) { File sroot = new File(root); if (sroot.exists()) { - String testXref = constructXrefLocation(true); - directories.add(new PmdFileInfo(localProject, sroot, testXref)); + String testSourceXref = linkXRef ? constructXrefLocation(xrefTestLocation, true) : null; + directories.add(new PmdFileInfo(localProject, sroot, testSourceXref)); } } }