This is an automated email from the ASF dual-hosted git repository. michaelo pushed a commit to branch doxia-2.0.0-ga in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git
commit 8f78bc507e929ed8c7c09cdafe93d8c8cedb75fe Author: Michael Osipov <micha...@apache.org> AuthorDate: Thu Oct 10 20:25:56 2024 +0200 Draft for MSHARED-1438 --- .../maven/plugins/pmd/AbstractPmdReport.java | 54 +++------------------- 1 file changed, 6 insertions(+), 48 deletions(-) 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 2fab848..fbf2159 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 java.util.TreeMap; 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.reporting.MavenReportException; 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 @@ public abstract class AbstractPmdReport extends AbstractMavenReport { 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<ReportPlugin> reportPlugins = - reporting != null ? reporting.getPlugins() : Collections.<ReportPlugin>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 @@ public abstract class AbstractPmdReport extends AbstractMavenReport { 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 @@ public abstract class AbstractPmdReport extends AbstractMavenReport { 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 @@ public abstract class AbstractPmdReport extends AbstractMavenReport { 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 @@ public abstract class AbstractPmdReport extends AbstractMavenReport { 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)); } } }