maven-plugins/simian/plugin.jelly

148 lines
4.9 KiB
XML

<?xml version="1.0"?>
<!--
/*
* Copyright 2001-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.
*/
-->
<!--
! Maven plugin for Simian
!
! Author: Aslak Hellesoy (aslak@thoughtworks.com)
-->
<project
xmlns:j="jelly:core"
xmlns:define="jelly:define"
xmlns:doc="doc"
xmlns:ant="jelly:ant"
xmlns:simian="simian">
<goal name="maven-simian-plugin"
description="Generate Simian (Code Similarity Analyzer) report."
prereqs="maven-simian-plugin:report"/>
<goal name="maven-simian-plugin:register">
<j:if test="${sourcesPresent}">
<doc:registerReport
name="Simian Report"
pluginName="maven-simian-plugin"
link="simian-report"
description="Simian (Code Similarity Analyzer) report."/>
</j:if>
</goal>
<goal name="maven-simian-plugin:deregister">
<doc:deregisterReport name="Simian"/>
</goal>
<goal name="maven-simian-plugin:analyze">
<ant:taskdef name="simian" classname="org.apache.maven.simian.FileSimianTask">
<ant:classpath>
<ant:pathelement location="${plugin.dir}"/>
<ant:pathelement location="${plugin.getDependencyPath('redhill:simian')}"/>
</ant:classpath>
</ant:taskdef>
<echo>Generating the Simian raw report ...</echo>
<ant:simian threshold="${maven.simian.linecount}">
<formatter type="plain" toFile="${maven.build.dir}/simian-raw-report.log"/>
<formatter type="xml" toFile="${maven.build.dir}/simian-raw-report.xml"/>
<ant:fileset dir="${pom.build.sourceDirectory}">
<ant:include name="${maven.simian.includes}"/>
<ant:exclude name="${maven.simian.excludes}"/>
<!-- FIXME: This is a bad cut and paste -->
<!-- handle source modifications -->
<j:forEach var="sm" items="${pom.build.sourceModifications}">
<ant:available property="classPresent" classname="${sm.className}"/>
<j:if test="${classPresent != 'true'}">
<j:forEach var="exclude" items="${sm.excludes}">
<ant:exclude name="${exclude}"/>
</j:forEach>
<j:forEach var="include" items="${sm.includes}">
<ant:include name="${include}"/>
</j:forEach>
</j:if>
</j:forEach>
</ant:fileset>
<j:set var="includeTests" value="${maven.simian.includetests}"/>
<j:if test="${includeTests == 'true'}">
<j:if test="${unitTestSourcesPresent == 'true'}">
<ant:fileset dir="${pom.build.unitTestSourceDirectory}">
<ant:include name="${maven.simian.testincludes}"/>
<ant:exclude name="${maven.simian.testexcludes}"/>
</ant:fileset>
</j:if>
</j:if>
<j:set var="ignoreStrings" value="${maven.simian.ignorestrings}"/>
<j:if test="${ignoreStrings == 'true'}">
<ant:setProperty name="ignoreStrings" value="${ignoreStrings}" />
</j:if>
<j:set var="ignoreStringCase" value="${maven.simian.ignorestringcase}"/>
<j:if test="${ignoreStringCase == 'true'}">
<ant:setProperty name="ignoreStringCase" value="${ignoreStringCase}" />
</j:if>
<j:set var="ignoreNumbers" value="${maven.simian.ignorenumbers}"/>
<j:if test="${ignoreNumbers == 'true'}">
<ant:setProperty name="ignoreNumbers" value="${ignoreNumbers}" />
</j:if>
<j:set var="ignoreSubtypeNames" value="${maven.simian.ignoresubtypenames}"/>
<j:if test="${ignoreSubtypeNames == 'true'}">
<ant:setProperty name="ignoreSubtypeNames" value="${ignoreSubtypeNames}" />
</j:if>
<j:set var="ignoreModifiers" value="${maven.simian.ignoremodifiers}"/>
<j:if test="${ignoreModifiers == 'true'}">
<ant:setProperty name="ignoreModifiers" value="${ignoreModifiers}" />
</j:if>
</ant:simian>
<!-- Run JSL to transform the report into XDOC -->
<echo>Converting the Simian report to xdoc ...</echo>
<doc:jsl
input="${maven.build.dir}/simian-raw-report.xml"
output="simian-report.xml"
stylesheet="${plugin.resources}/simian.jsl"
outputMode="xml"
prettyPrint="true"
/>
</goal>
<goal name="maven-simian-plugin:report">
<j:choose>
<j:when test="${sourcesPresent}">
<attainGoal name="maven-simian-plugin:analyze"/>
</j:when>
<j:otherwise>
<ant:echo>No sources to run Simian on</ant:echo>
</j:otherwise>
</j:choose>
</goal>
</project>