blob: 8252ac4e2266b59289b1ddaaf264bb003d4e05ad [file] [log] [blame]
<!--
******************************************************************************
* Copyright (c) 2016 Oracle
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Konstantin Komissarchik - initial implementation and ongoing maintenance
******************************************************************************
-->
<project name="corundum.macro.findbugs">
<macrodef name="findbugs">
<sequential>
<if>
<istrue value="${findbugs}"/>
<then>
<locate-findbugs/>
<locate-source/>
<build-repository/>
<property name=".findbugs.output" value="${build.dir}/findbugs"/>
<delete dir="${.findbugs.output}" quiet="true"/>
<mkdir dir="${.findbugs.output}"/>
<taskdef name="findbugs-task" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
<classpath>
<fileset dir="${findbugs.location}/lib">
<include name="*.jar"/>
</fileset>
</classpath>
</taskdef>
<var name=".aux.xml" unset="true"/>
<var name=".aux.xml.contribution" unset="true"/>
<with-target name="${configuration.recommended}">
<for-each-eclipse-bundle eclipse="${.target}">
<if>
<available file="${.bundle.location}" type="dir"/>
<then>
<pathconvert property=".aux.xml.contribution" pathsep="&lt;/AuxClasspathEntry&gt;&#xA;&lt;AuxClasspathEntry&gt;">
<path>
<fileset dir="${.bundle.location}">
<include name="**/*.jar"/>
</fileset>
</path>
</pathconvert>
</then>
<else>
<var name=".aux.xml.contribution" value="${.bundle.location}"/>
</else>
</if>
<append property=".aux.xml" value="${.aux.xml.contribution}" separator="&lt;/AuxClasspathEntry&gt;&#xA;&lt;AuxClasspathEntry&gt;"/>
<var name=".aux.xml.contribution" unset="true"/>
</for-each-eclipse-bundle>
</with-target>
<pathconvert property=".source.xml" pathsep="&lt;/SrcDir&gt;&#xA;&lt;SrcDir&gt;">
<path>
<dirset dir="${source.location}/plugins" includes="*/src"/>
</path>
</pathconvert>
<pathconvert property=".jars.xml" pathsep="&lt;/Jar&gt;&#xA;&lt;Jar&gt;">
<path>
<fileset dir="${build.dir}/repository" includes="${findbugs.includes}" excludes="${findbugs.excludes}"/>
</path>
</pathconvert>
<echo file="${.findbugs.output}/project.xml">
&lt;BugCollection>
&lt;Project filename="findbugs.project" projectName="FindBugs Analysis">
&lt;Jar&gt;${.jars.xml}&lt;/Jar&gt;
&lt;AuxClasspathEntry&gt;${.aux.xml}&lt;/AuxClasspathEntry&gt;
&lt;SrcDir&gt;${.source.xml}&lt;/SrcDir&gt;
&lt;SuppressionFilter&gt;
&lt;LastVersion value="-1" relOp="NEQ"/&gt;
&lt;/SuppressionFilter&gt;
&lt;/Project&gt;
&lt;/BugCollection&gt;
</echo>
<var name=".aux.xml" unset="true"/>
<var name=".source.xml" unset="true"/>
<var name=".jars.xml" unset="true"/>
<findbugs-task
home="${findbugs.location}"
projectFile="${.findbugs.output}/project.xml"
excludeFilter="${source.location}/findbugs-excludes.xml"
output="xml"
outputFile="${.findbugs.output}/result.xml"
timeout="3600000"
jvmargs="-Xmx4096m"/>
<var name=".findbugs.output" unset="true"/>
</then>
</if>
</sequential>
</macrodef>
</project>