Files
maven-plugins/checkstyle/src/plugin-resources/checkstyle-all.jsl
T
ltheussl c220304aac PR: MPCHECKSTYLE-52
The links to source xref files does not honor maven.jxr.destdir
and maven.jxr.destdir.test.


git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@378121 13f79535-47bb-0310-9956-ffa450edef68
2006-02-15 23:44:41 +00:00

265 lines
13 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!--
* ========================================================================
*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ========================================================================
-->
<jsl:stylesheet
select="$doc"
xmlns:j="jelly:core"
xmlns:jsl="jelly:jsl"
xmlns:util="jelly:util"
xmlns:x="jelly:xml"
xmlns:maven="jelly:maven"
xmlns:doc="doc"
xmlns="dummy" trim="true">
<!-- This needs to be instantiated here to be available in the template matches -->
<j:useBean var="mavenTool" class="org.apache.maven.util.MavenTool"/>
<j:useBean var="htmlescape" class="org.apache.velocity.anakia.Escape"/>
<j:useBean var="fileutil" class="org.apache.velocity.texen.util.FileUtil"/>
<j:useBean var="pathtool" class="org.apache.maven.util.DVSLPathTool"/>
<jsl:template match="checkstyle">
<document>
<properties>
<title>Checkstyle Results</title>
</properties>
<body>
<section name="Checkstyle Results">
<p>
The following document contains the results of
<a href="http://checkstyle.sourceforge.net/">Checkstyle</a>
<a href="checkstyle.rss"><img src="../images/rss.png"/></a>.
</p>
</section>
<section name="Summary">
<j:set var="fileCount"><x:expr select="count(file)"/></j:set>
<j:set var="infoCount"><x:expr select="count(file/error[@severity='info'])"/></j:set>
<j:set var="warningCount"><x:expr select="count(file/error[@severity='warning'])"/></j:set>
<j:set var="errorCount"><x:expr select="count(file/error[@severity='error'])"/></j:set>
<table summary="Report summary">
<thead>
<tr>
<th>Files</th>
<th style="width:75px">Infos</th>
<th style="width:75px">Warnings</th>
<th style="width:75px">Errors</th>
</tr>
</thead>
<tbody>
<tr>
<td><doc:formatAsNumber string="${fileCount}" pattern="0"/></td>
<td><doc:formatAsNumber string="${infoCount}" pattern="0"/></td>
<td><doc:formatAsNumber string="${warningCount}" pattern="0"/></td>
<td><doc:formatAsNumber string="${errorCount}" pattern="0"/></td>
</tr>
</tbody>
</table>
</section>
<section name="Files">
<table summary="Files">
<thead>
<tr>
<th>Files</th>
<th style="width:30px">I</th>
<th style="width:30px">W</th>
<th style="width:30px">E</th>
</tr>
</thead>
<tbody>
<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:if test="${pom.build.unitTestSourceDirectory != null}">
<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}"/>
</j:if>
<x:set var="files" select="file" sort="@name"/>
<!-- 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="srcRelPathLen" value="${pathtool.getRelativePath(srcDir,name).length()}"/>
<j:if test="${srcRelPathLen > 0}">
<j:set var="name" value="${name.substring(mavenTool.toInteger(srcDirLength.toString()))}"/>
</j:if>
<j:if test="${pom.build.unitTestSourceDirectory != null}">
<j:set var="tstRelPathLen" value="${pathtool.getRelativePath(tstDir,name).length()}"/>
<j:if test="${tstRelPathLen > 0}">
<j:set var="name" value="${name.substring(mavenTool.toInteger(tstDirLength.toString()))}"/>
</j:if>
</j:if>
<util:replace var="name" value="${name}" oldChar="\\" newChar="/"/>
<!--- +1 is for the trailing slash above -->
<j:set var="infoCount"><x:expr select="count($file/error[@severity='info'])"/></j:set>
<j:set var="warningCount"><x:expr select="count($file/error[@severity='warning'])"/></j:set>
<j:set var="errorCount"><x:expr select="count($file/error[@severity='error'])"/></j:set>
<j:if test="${errorCount + warningCount + infoCount != 0}">
<tr>
<td>
<a href="#${name}">${name}</a>
</td>
<td><doc:formatAsNumber string="${infoCount}" pattern="0"/></td>
<td><doc:formatAsNumber string="${warningCount}" pattern="0"/></td>
<td><doc:formatAsNumber string="${errorCount}" pattern="0"/></td>
</tr>
</j:if>
</j:forEach>
</tbody>
</table>
<!-- Where documentations are generated -->
<j:set var="docsDestDir" value="${maven.docs.dest}"/>
<util:replace var="docsDestDir" value="${docsDestDir}" oldChar="\\" newChar="/"/>
<!-- JXR is activated ? -->
<j:set var="jxrActivated" value="false"/>
<j:forEach var="report" items="${pom.reports}">
<j:if test="${report.equals('maven-jxr-plugin')}">
<j:set var="jxrActivated" value="true"/>
</j:if>
</j:forEach>
<j:if test="${pom.build.sourceDirectory != null}">
<!-- Where JXR files are generated for the code -->
<j:set var="jxrDestDir" value="${maven.jxr.destdir}"/>
<util:replace var="jxrDestDir" value="${jxrDestDir}" oldChar="\\" newChar="/"/>
<j:choose>
<j:when test="${jxrActivated and jxrDestDir.startsWith(docsDestDir)}">
<!-- We create a relative path to the jxr files -->
<!-- ${maven.jxr.destdir} should be a subdirectory of ${maven.docs.dest} -->
<j:set var="jxrDestDir" value="${jxrDestDir.substring(docsDestDir.length(),jxrDestDir.length())}"/>
<!-- remove first slash if needed -->
<j:if test="${jxrDestDir.startsWith('/')}">
<j:set var="jxrDestDir" value="${jxrDestDir.substring(1,jxrDestDir.length())}"/>
</j:if>
</j:when>
<j:otherwise>
<!-- Do not generate the link -->
<j:set var="jxrDestDir" value=""/>
</j:otherwise>
</j:choose>
</j:if>
<j:if test="${pom.build.unitTestSourceDirectory != null}">
<!-- Where JXR files are generated for the tests -->
<j:set var="jxrTestDestDir" value="${maven.jxr.destdir.test}"/>
<util:replace var="jxrTestDestDir" value="${jxrTestDestDir}" oldChar="\\" newChar="/"/>
<maven:get var="xrefGeneratedForTests" plugin="maven-jxr-plugin" property="maven.jxr.include.testXref"/>
<j:choose>
<j:when test="${jxrActivated and xrefGeneratedForTests and jxrTestDestDir.startsWith(docsDestDir)}">
<!-- We create a relative path to the jxr files for tests -->
<!-- ${maven.jxr.destdir.test} should be a subdirectory of ${maven.docs.dest} -->
<j:set var="jxrTestDestDir" value="${jxrTestDestDir.substring(docsDestDir.length(),jxrTestDestDir.length())}"/>
<!-- remove first slash if needed -->
<j:if test="${jxrTestDestDir.startsWith('/')}">
<j:set var="jxrTestDestDir" value="${jxrTestDestDir.substring(1,jxrTestDestDir.length())}"/>
</j:if>
</j:when>
<j:otherwise>
<!-- Do not generate the link -->
<j:set var="jxrTestDestDir" value=""/>
</j:otherwise>
</j:choose>
</j:if>
<j:forEach var="file" items="${files}">
<x:set var="errorCount" select="count($file/error)"/>
<j:if test="${errorCount != 0}">
<j:set var="name" value="${file.attribute('name').getValue()}"/>
<j:set var="srcRelPathLen" value="${pathtool.getRelativePath(srcDir,name).length()}"/>
<j:set var="jxrPath" value=""/>
<j:if test="${srcRelPathLen > 0 and jxrActivated}">
<j:set var="name" value="${name.substring(mavenTool.toInteger(srcDirLength.toString()))}"/>
<j:set var="jxrPath" value="../${jxrDestDir}"/>
</j:if>
<j:if test="${pom.build.unitTestSourceDirectory != null}">
<j:set var="tstRelPathLen" value="${pathtool.getRelativePath(tstDir,name).length()}"/>
<j:if test="${tstRelPathLen > 0 and jxrActivated}">
<j:set var="name" value="${name.substring(mavenTool.toInteger(tstDirLength.toString()))}"/>
<j:set var="jxrPath" value="../${jxrTestDestDir}"/>
</j:if>
</j:if>
<util:replace var="name" value="${name}" oldChar="\\" newChar="/"/>
<subsection name="${name}">
<table summary="Error details for ${name}">
<thead>
<tr>
<th colspan="2">Error</th>
<th style="width:20px">Line</th>
</tr>
</thead>
<x:set var="errors" select="$file/error"/>
<j:forEach var="error" items="${errors}">
<tbody>
<tr>
<td style="width:20px">
<j:set var="severity" value="${error.attribute('severity').getValue()}"/>
<j:choose>
<j:when test="${severity == 'error'}">
<img src="../images/icon_error_sml.gif" width="15" height="15" alt="Error" />
</j:when>
<j:when test="${severity == 'warning'}">
<img src="../images/icon_warning_sml.gif" width="15" height="15" alt="Warning" />
</j:when>
<j:when test="${severity == 'info'}">
<img src="../images/icon_info_sml.gif" width="15" height="15" alt="Info" />
</j:when>
</j:choose>
</td>
<td>
<j:set var="errorMessage" value="${error.attribute('message').getValue()}"/>
${htmlescape.getText(errorMessage)}
</td>
<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 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="${jxrPath}/${nameWithoutJavaExtension}.html#${line}">${line}</a>
</j:when>
<j:otherwise>
${line}
</j:otherwise>
</j:choose>
</td>
</tr>
</tbody>
</j:forEach>
</table>
</subsection>
</j:if>
</j:forEach>
</section>
</body>
</document>
</jsl:template>
</jsl:stylesheet>