All Downloads are FREE. Search and download functionalities are using the official Maven repository.

4j.sanity4j.1.0.7.source-code.sanity4j-ant.xml Maven / Gradle / Ivy

Go to download

Sanity4J was created to simplify running multiple static code analysis tools on the Java projects. It provides a single entry point to run all the selected tools and produce a consolidated report, which presents all findings in an easily accessible manner.

There is a newer version: 1.1.1
Show newest version
<?xml version="1.0"?>
<!-- *******************************************************************
**
** NAME
** sanity4j-ant.xml
**
** PURPOSE
** This file is an XML (eXtensible Mark-up Language) file used to define
** an Apache ANT (http://ant.apache.org) library.
**
** This macro performs code quality assurance tests using various third
** party tools.
**
** USAGE
** Ensure that you are running at least Java 1.5, as some of the tools
** don't work on 1.4 or earlier VMs.
**
** Within a project's build.xml file, include the following line:
**
**   <typedef
**       resource  ="sanity4j-ant.xml"
**       classpath ="${yourSanity4JLibDir}/sanity4j.jar"/>
**
** MACROS
**   sanity4j.run - Runs Sanity4J against a project
**   sanity4j     - Runs Sanity4J against a project, with support
**                  for aggregation of coverage data files.
**
** AUTHOR
** Yiannis Paschalidis, 2008.
**
******************************************************************** -->

<antlib>

    <!-- ***************************************************************
    ** TYPE DEFINITIONS
    **************************************************************** -->

    <typedef name="configuration" classname="net.sf.sanity4j.ant.taskdef.RunQA$Configuration"/>

    <!-- ***************************************************************
    ** TASK DEFINITIONS
    **************************************************************** -->

    <!-- ***************************************************************
    ** This runs the QA tools against a project and produces the raw
    ** output that is used to generate the reports. Projects should use
    ** the sanity4j.run macro instead.
    **
    ** The QA tools are run using java code rather than a macro as
    **  - the ant Tasks for tools use different types (e.g. not all allow FileSets)
    **  - Most tools don't support multiple source directories
    **  - It's less of a pain for an end user to set a few top-level directories
    **    and let the task figure out what the source/class paths should be.
    **
    **************************************************************** -->

    <typedef name="sanity4j.runtask" classname="net.sf.sanity4j.ant.taskdef.RunQA"/>

    <!-- ***************************************************************
    ** MACRO DEFINITIONS
    **************************************************************** -->

    <!-- ***************************************************************
    ** This runs the QA tools against a project and produces reports that
    ** can be published on a web server.
    **
    **  Attributes:
    **
    **     products.dir
    **
    **          The location of the products VOB containing the QA tools
    **          (FindBugs, PMD, CheckStyle, etc.)
    **
    **     report.dir
    **
    **          The report output directory. Sub-directories will be created
    **          for each type of report.
    **
    **     coverage.data.file [optional]
    **
    **          A coverage data file (e.g. cobertura.ser) if you want to
    **          include unit testing coverage data in your report.
    **
    **     summary.data.file [optional]
    **
    **          The location of a (persistent) file to store summary data, if
    **          you want to include trend graphs in your report.
    **
    **     include.tool.output [optional]
    **
    **          If set to "true", the raw tool output is also copied to the
    **          report directory.
    **
    **     external.properties.path [optional]
    **
    **          The location of the sanity4j.properties.
    **          Defaults to the current directory.
    **
    **     java.runtime [optional]
    **
    **          The location of the java executable; 1.5 or later.
    **
    ** Elements:
    **
    **     source.path
    **
    **          This element accepts nested Paths pointing to
    **          the location of *this* project's source only.
    **          If you have multiple source directories contained within
    **          a main directory, you can just list the main directory
    **          here - the task will search for all source directories.
    **
    **     class.path
    **
    **          This element accepts nested Paths pointing to
    **          the location of *this* project's built classes/jars only
    **
    **     library.path
    **
    **          This element accepts nested Paths pointing to
    **          the location of jars/classes that this project depends on.
    **          Don't use e.g. an entire local Maven repository. Only include
    **          libraries which the project directly depends on.
    **
    **     configurations
    **
    **          This element accepts nested configuration elements,
    **          describing parameters that are passed to the underlying tools
    **          (CheckStyle, FindBugs, PMD, etc...) to configure the particular
    **          tool.
    **
    ** EXAMPLE:
    **
    **     <sanity4j.run
    **         products.dir="${component.rootdir}/tools"
    **         report.dir="${build.dir}/reports">
    **
    **         <source.path>
    **             <path path="${component.rootdir}"/>
    **         </source.path>
    **         <class.path>
    **             <path path="${build.dir}/libs"/>
    **         </class.path>
    **         <library.path>
    **             <path>
    **                 <fileset dir="${yourRepository}">
    **                     <include name="yourDependency1/**/*.jar"/>
    **                     <include name="yourDependency2/**/*.jar"/>
    **                 </fileset>
    **             </path>
    **         </library.files>
    **         <configurations>
    **             <configuration tool="checkstyle" config="local-checkstyle.xml"/>
    **         </configurations>
    **     </sanity4j.run>
    **
    **************************************************************** -->
    <macrodef name="sanity4j.run">

        <attribute name="products.dir"/>
        <attribute name="report.dir"/>
        <attribute name="coverage.data.file" default=""/>
        <attribute name="summary.data.file" default=""/>
        <attribute name="java.runtime" default="java"/>
        <attribute name="include.tool.output" default="false"/>
        <attribute name="external.properties.path" default=""/>

        <element name="source.path"/>
        <element name="class.path"/>
        <element name="library.path"/>
        <element name="coverage.data.files"/>
        <element name="configurations" optional="true"/>

        <sequential>

            <!-- delete all old data/reports -->
            <delete dir="@{report.dir}" failonerror="false" />
            <mkdir dir="@{report.dir}" />

            <!-- generate the raw output -->
            <echo message="Performing QA analysis"/>

            <sanity4j.runtask
                productsDir="@{products.dir}"
                reportDir="@{report.dir}"
                coverageDataFile="@{coverage.data.file}"
                summaryDataFile="@{summary.data.file}"
                javaRuntime="@{java.runtime}"
                includeToolOutput="@{include.tool.output}"
                externalPropertiesPath="@{external.properties.path}">

                <sourcepath>
                    <source.path/>
                </sourcepath>

                <classpath>
                    <class.path/>
                </classpath>

                <librarypath>
                    <library.path/>
                </librarypath>

                <configurations/>

            </sanity4j.runtask>

        </sequential>

    </macrodef>

    <!-- ***************************************************************
    ** This runs the QA tools against a project and produces reports that
    ** can be published on a web server.
    **
    **  Attributes:
    **
    **     products.dir
    **
    **          The location of the products VOB containing the QA tools
    **          (FindBugs, PMD, CheckStyle, etc.)
    **
    **     report.dir
    **
    **          The report output directory. Sub-directories will be created
    **          for each type of report.
    **
    **     coverage.merge.data.file [optional]
    **
    **          A coverage data file (e.g. cobertura-merged.ser) if you want to
    **          merge multiple coverage data files into single report.
    **
    **     summary.data.file [optional]
    **
    **          The location of a (persistent) file to store summary data, if
    **          you want to include trend graphs in your report.
    **
    **     include.tool.output [optional]
    **
    **          If set to "true", the raw tool output is also copied to the
    **          report directory.
    **
    **     external.properties.path [optional]
    **
    **          The location of the sanity4j.properties.
    **          Defaults to the current directory.
    **
    **     java.runtime [optional]
    **
    **          The location of the java executable; 1.5 or later.
    **
    ** Elements:
    **
    **     source.path
    **
    **          This element accepts nested Paths pointing to
    **          the location of *this* project's source only.
    **          If you have multiple source directories contained within
    **          a main directory, you can just list the main directory
    **          here - the task will search for all source directories.
    **
    **     class.path
    **
    **          This element accepts nested Paths pointing to
    **          the location of *this* project's built classes/jars only
    **
    **     library.path
    **
    **          This element accepts nested Paths pointing to
    **          the location of jars/classes that this project depends on.
    **          Don't use e.g. an entire local Maven repository. Only include
    **          libraries which the project directly depends on.
    **
    **     coverage.data.files
    **
    **          This element accepts nested Paths pointing to
    **          the location of coverage data files to be merged.
    **
    **     configurations
    **
    **          This element accepts nested configuration elements,
    **          describing parameters that are passed to the underlying tools
    **          (CheckStyle, FindBugs, PMD, etc...) to configure the particular
    **          tool.
    **
    ** EXAMPLE:
    **
    **     <sanity4j
    **         products.dir="${component.rootdir}/tools"
    **         report.dir="${build.dir}/reports"
    **         coverage.merge.data.file="${build.dir}/cobertura-merged.ser">
    **
    **         <source.path>
    **             <path path="${component.rootdir}"/>
    **         </source.path>
    **         <class.path>
    **             <path path="${build.dir}/libs"/>
    **         </class.path>
    **         <library.path>
    **             <path>
    **                 <fileset dir="${yourRepository}">
    **                     <include name="yourDependency1/**/*.jar"/>
    **                     <include name="yourDependency2/**/*.jar"/>
    **                 </fileset>
    **             </path>
    **         </library.files>
    **         <coverage.data.files>
    **             <path path="${build.dir}/yourProject1/cobertura.ser"/>
    **             <path path="${build.dir}/yourProject2/cobertura.ser"/>
    **         </coverage.data.files>
    **         <configurations>
    **             <configuration tool="checkstyle" config="local-checkstyle.xml"/>
    **         </configurations>
    **     </sanity4j>
    **
    **************************************************************** -->
    <macrodef name="sanity4j">

        <attribute name="products.dir"/>
        <attribute name="report.dir"/>
        <attribute name="coverage.merge.data.file" default="cobertura-merged.ser"/>
        <attribute name="summary.data.file" default=""/>
        <attribute name="java.runtime" default="java"/>
        <attribute name="include.tool.output" default="false"/>
        <attribute name="external.properties.path" default=""/>

        <element name="source.path"/>
        <element name="class.path"/>
        <element name="library.path"/>
        <element name="coverage.data.files"/>
        <element name="configurations" optional="true"/>

        <sequential>

            <!-- delete all old data/reports -->
            <delete dir="@{report.dir}" failonerror="false" />
            <mkdir dir="@{report.dir}" />

            <!-- generate the raw output -->
            <echo message="Performing QA analysis"/>
            <sanity4j.runtask
                productsDir="@{products.dir}"
                reportDir="@{report.dir}"
                coverageMergeDataFile="@{coverage.merge.data.file}"
                summaryDataFile="@{summary.data.file}"
                javaRuntime="@{java.runtime}"
                includeToolOutput="@{include.tool.output}"
                externalPropertiesPath="@{external.properties.path}">

                <sourcepath>
                    <source.path/>
                </sourcepath>

                <classpath>
                    <class.path/>
                </classpath>

                <librarypath>
                    <library.path/>
                </librarypath>

                <coveragedatafiles>
                    <coverage.data.files/>
                </coveragedatafiles>

                <configurations/>

            </sanity4j.runtask>

        </sequential>

    </macrodef>

</antlib>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy