Author: ltheussl
Date: Mon Jan 23 16:35:13 2006
New Revision: 371741
URL: http://svn.apache.org/viewcvs?rev=371741&view=rev
Log:
Fix links generated for jxr test files
Modified:
maven/maven-1/plugins/trunk/pmd/src/plugin-resources/pmd.jsl
Modified: maven/maven-1/plugins/trunk/pmd/src/plugin-resources/pmd.jsl
URL:
http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/pmd/src/plugin-resources/pmd.jsl?rev=371741&r1=371740&r2=371741&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/pmd/src/plugin-resources/pmd.jsl (original)
+++ maven/maven-1/plugins/trunk/pmd/src/plugin-resources/pmd.jsl Mon Jan 23
16:35:13 2006
@@ -75,12 +75,22 @@
<j:set var="fullSrcDir" value="${pom.build.sourceDirectory}"/>
<j:set var="srcDir"
value="${fileutil.file(fullSrcDir).getCanonicalPath()}"/>
<j:set var="srcDirLength" value="${srcDir.length() + 1}"/>
+ <j:set var="fullTstDir"
value="${pom.build.unitTestSourceDirectory}"/>
+ <j:set var="tstDir"
value="${fileutil.file(fullTstDir).getCanonicalPath()}"/>
+ <j:set var="tstDirLength" value="${tstDir.length() + 1}"/>
<x:set var="files" select="file"/>
<!-- x:forEach is busted -->
<j:forEach var="file" items="${files}">
<!-- Type coercion doesn't work worth a fuck in jexl. -->
<j:set var="name" value="${file.attribute('name').getValue()}"/>
- <j:set var="name"
value="${name.substring(mavenTool.toInteger(srcDirLength.toString()))}"/>
+ <j:set var="srcRelPathLen"
value="${pathtool.getRelativePath(srcDir,name).length()}"/>
+ <j:set var="tstRelPathLen"
value="${pathtool.getRelativePath(tstDir,name).length()}"/>
+ <j:if test="${srcRelPathLen > 0}">
+ <j:set var="name"
value="${name.substring(mavenTool.toInteger(srcDirLength.toString()))}"/>
+ </j:if>
+ <j:if test="${tstRelPathLen > 0}">
+ <j:set var="name"
value="${name.substring(mavenTool.toInteger(tstDirLength.toString()))}"/>
+ </j:if>
<util:replace var="name" value="${name}" oldChar="\\"
newChar="/"/>
<!--- +1 is for the trailing slash above -->
<j:set var="errorCount"><x:expr
select="count($file/violation)"/></j:set>
@@ -100,7 +110,19 @@
<x:set var="errorCount" select="count($file/violation)"/>
<j:if test="${errorCount != 0}">
<j:set var="name" value="${file.attribute('name').getValue()}"/>
- <j:set var="name"
value="${name.substring(mavenTool.toInteger(srcDirLength.toString()))}"/>
+ <j:set var="srcRelPathLen"
value="${pathtool.getRelativePath(srcDir,name).length()}"/>
+ <j:set var="tstRelPathLen"
value="${pathtool.getRelativePath(tstDir,name).length()}"/>
+ <j:set var="jxrPath" value=""/>
+ <j:if test="${srcRelPathLen > 0}">
+ <j:set var="name"
value="${name.substring(mavenTool.toInteger(srcDirLength.toString()))}"/>
+ <!-- FIXME: this should be determined by ${maven.jxr.destdir}
-->
+ <j:set var="jxrPath" value="xref"/>
+ </j:if>
+ <j:if test="${tstRelPathLen > 0}">
+ <j:set var="name"
value="${name.substring(mavenTool.toInteger(tstDirLength.toString()))}"/>
+ <!-- FIXME: this should be determined by
${maven.jxr.destdir.test} -->
+ <j:set var="jxrPath" value="xref-test"/>
+ </j:if>
<util:replace var="name" value="${name}" oldChar="\\"
newChar="/"/>
<subsection name="${name}">
@@ -119,12 +141,13 @@
<td>
<j:set var="line"
value="${error.attribute('line').getValue()}"/>
<j:set var="lastIndex"
value="${name.lastIndexOf('.java')}"/>
+ <j:set var="jxrPathLen" value="${jxrPath.length()}"/>
<j:choose>
- <j:when test="${lastIndex > 0}">
+ <j:when test="${lastIndex > 0 and jxrPathLen > 0}">
<j:set var="index"
value="${mavenTool.toInteger(lastIndex.toString())}"/>
<j:set var="nameWithoutJavaExtension"
value="${name.substring(0, index)}"/>
<util:replace var="nameWithoutJavaExtension"
value="${nameWithoutJavaExtension}" oldChar="\\" newChar="/"/>
- <a
href="xref/${nameWithoutJavaExtension}.html#${line}">${line}</a>
+ <a
href="${jxrPath}/${nameWithoutJavaExtension}.html#${line}">${line}</a>
</j:when>
<j:otherwise>
${line}