Skip to content

Commit

Permalink
[MPMD-407] Upgrade to Doxia 2.0.0 GA Stack
Browse files Browse the repository at this point in the history
This closes #175
  • Loading branch information
michael-o committed Oct 19, 2024
1 parent c57895e commit e99d2e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 51 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ under the License.
<pmdVersion>7.3.0</pmdVersion>
<slf4jVersion>1.7.36</slf4jVersion>
<resolverVersion>1.4.1</resolverVersion>
<doxiaVersion>2.0.0-M12</doxiaVersion>
<doxiaVersion>2.0.0</doxiaVersion>
<compilerPluginVersion>3.11.0</compilerPluginVersion>
<sitePluginVersion>3.20.0</sitePluginVersion>
<projectInfoReportsPluginVersion>3.7.0</projectInfoReportsPluginVersion>
<jxrPluginVersion>3.4.0</jxrPluginVersion>
<jxrPluginVersion>3.5.0</jxrPluginVersion>
<project.build.outputTimestamp>2024-08-22T16:42:52Z</project.build.outputTimestamp>
</properties>

Expand Down Expand Up @@ -212,7 +212,7 @@ under the License.
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-impl</artifactId>
<version>4.0.0-M15</version>
<version>4.0.0</version>
</dependency>

<!-- plexus -->
Expand Down
54 changes: 6 additions & 48 deletions src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

/**
Expand Down Expand Up @@ -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<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
*
Expand Down Expand Up @@ -355,7 +313,7 @@ protected Map<File, PmdFileInfo> 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));
}
}
Expand All @@ -368,8 +326,8 @@ protected Map<File, PmdFileInfo> 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));
}
}
}
Expand All @@ -379,7 +337,7 @@ protected Map<File, PmdFileInfo> 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));
}
}
Expand All @@ -388,8 +346,8 @@ protected Map<File, PmdFileInfo> 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));
}
}
}
Expand Down

0 comments on commit e99d2e4

Please sign in to comment.