Permalink
Fetching contributors…
Cannot retrieve contributors at this time
executable file 334 lines (298 sloc) 18.5 KB
<!-- fb-contrib Ant build script. Dave Brosius -->
<project name="fb-contrib" default="default">
<presetdef name="javac">
<javac encoding="UTF-8" />
</presetdef>
<presetdef name="javadoc">
<javadoc encoding="UTF-8" />
</presetdef>
<property file="user.properties" />
<property file="build.properties" />
<property file="version.properties" />
<property name="src.dir" value="${basedir}/src/main/java" />
<property name="lib.dir" value="${basedir}/lib" />
<property name="etc.dir" value="${basedir}/etc" />
<property name="test.dir" value="${basedir}/src/test/java" />
<property name="target.dir" value="${basedir}/target" />
<property name="samples.dir" value="${basedir}/src/samples/java" />
<property name="main.classes.dir" value="${target.dir}/classes/main" />
<property name="samples.classes.dir" value="${target.dir}/classes/samples" />
<property name="test.classes.dir" value="${target.dir}/classes/test" />
<property name="javadoc.dir" value="${target.dir}/javadoc" />
<property name="htdocs.dir" value="${basedir}/htdocs" />
<property name="javac.source" value="1.7" />
<property name="javac.target" value="1.7" />
<property name="javac.deprecation" value="on" />
<property name="javac.debug" value="on" />
<property name="test_reports.dir" value="${target.dir}/reports/test"/>
<property name="fb-contrib.version" value="7.0.3" />
<property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" />
<target name="clean" description="removes all generated collateral">
<delete dir="${target.dir}" />
<delete file="${htdocs.dir}/bugdescriptions.html" />
</target>
<target name="infra_jars" description="pull jars needed to build fb-contrib to ${user.dir}/.ant/lib">
<mkdir dir="${user.home}/.ant/lib" />
<get src="http://repo1.maven.org/maven2/com/mebigfatguy/yank/yank/1.8.0/yank-1.8.0.jar" dest="${user.home}/.ant/lib"/>
<get src="https://bitbucket.org/kjlubick/bugrankcheckstyle/downloads/bug-rank-check-style-1.0.0.jar" dest="${user.home}/.ant/lib"/>
<get src="http://repo1.maven.org/maven2/com/mebigfatguy/vcsversion/vcsversion/0.4.0/vcsversion-0.4.0.jar" dest="${user.home}/.ant/lib"/>
<get src="http://repo1.maven.org/maven2/com/mebigfatguy/fb-delta/fb-delta/0.6.0/fb-delta-0.6.0.jar" dest="${user.home}/.ant/lib" ignoreerrors="true"/>
<get src="http://repo1.maven.org/maven2/com/mebigfatguy/stringliterals/stringliterals/0.2.0/stringliterals-0.2.0.jar" dest="${user.home}/.ant/lib" ignoreerrors="true"/>
</target>
<target name="yank" xmlns:yank="antlib:com.mebigfatguy.yank" unless="no.yank">
<mkdir dir="${lib.dir}" />
<yank:yank yankFile="${basedir}/yank.xls" destination="${lib.dir}" proxyServer="${proxy.server}" source="true" separateClassifierTypes="true" checkSHADigests="true">
<server url="http://repo1.maven.org/maven2" />
<generateVersions propertyFileName="${basedir}/version.properties" />
</yank:yank>
</target>
<target name="info">
<echo message="fb-contrib - a findbugs plugin"/>
<echo message=""/>
<echo message=" This project requires three jars to build fb-contrib: yank, bug-rank-check-style, vcsversion and" />
<echo message=" and optionally fb-delta, to generate delta's of bug reports, as well as stringliterals to dump"/>
<echo message=" a report of all string literals used in the code"/>
<echo message=""/>
<echo message=" This project uses yank (https://github.com/mebigfatguy/yank) for dependency management"/>
<echo message=" download yank.jar and place in ~/.ant/lib directory"/>
<echo message=" http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.mebigfatguy.yank%22"/>
<echo message="===="/>
<echo message=" Additionally, this project uses bug-rank-check-style to validate etc/bugrank.txt"/>
<echo message=" bug-rank-check-style-1.0.0.jar can be downloaded at https://bitbucket.org/klubick/bugrankcheckstyle/downloads"/>
<echo message=" and put in ~/.ant/lib alongside yank"/>
<echo message="===="/>
<echo message=" Finally, this project uses vcsversion to inject the git version information into the manifest file"/>
<echo message=" and can be downloaded and placed in ~/.ant/lib as well"/>
<echo message=" http://search.maven.org/#search%7Cga%7C1%7Cvcsversion"/>
<echo message="===="/>
<echo message=" If you want to generate delta reports between two sample.xml runs, this project also uses fb-delta to do"/>
<echo message=" delta-ing between two samples.xml files, to report what has been 'fixed' and what is 'new'"/>
<echo message=" and can be downloaded and placed in ~/.ant/lib as well"/>
<echo message=" http://search.maven.org/#search%7Cga%7C1%7Cfb-delta"/>
<echo message="===="/>
<echo message=" If you want to generate a report of all string literals used in the code base, this project also uses stringliterals to do"/>
<echo message=" that, and can be downloaded and placed in ~/.ant/lib as well"/>
<echo message=" http://search.maven.org/#search%7Cga%7C1%7Cstringliterals"/>
<echo message="===="/>
<echo message=" This task can be automated by running ant infra_jars"/>
</target>
<target name="default" depends="info, install"/>
<target name="-init" depends="yank">
<mkdir dir="${lib.dir}" />
<mkdir dir="${main.classes.dir}" />
<mkdir dir="${test.classes.dir}" />
<mkdir dir="${samples.classes.dir}" />
<mkdir dir="${javadoc.dir}" />
<path id="fb-contrib.classpath">
<pathelement location="${lib.dir}/findbugs-${findbugs.version}.jar" />
<pathelement location="${lib.dir}/bcel-findbugs-${bcel-findbugs.version}.jar" />
<pathelement location="${lib.dir}/findbugs-annotations-${findbugs-annotations.version}.jar" />
<pathelement location="${lib.dir}/asm-debug-all-${asm-debug-all.version}.jar" />
<pathelement location="${main.classes.dir}" />
</path>
<path id="fb-contrib.test.classpath">
<pathelement location="${lib.dir}/testng-${testng.version}.jar" />
<pathelement location="${lib.dir}/jcommander-${jcommander.version}.jar" />
<pathelement location="${lib.dir}/mockito-core-${mockito-core.version}.jar" />
<pathelement location="${lib.dir}/hamcrest-core-${hamcrest-core.version}.jar" />
<pathelement location="${findbugs.dir}/lib/dom4j-1.6.1.jar" />
<pathelement location="${findbugs.dir}/lib/jaxen-1.1.6.jar" />
</path>
<path id="fb-contrib.samples.classpath">
<pathelement location="${lib.dir}/asm-debug-all-${asm-debug-all.version}.jar" />
<pathelement location="${lib.dir}/javax.servlet.jsp-api-${javax.servlet.jsp-api.version}.jar" />
<pathelement location="${lib.dir}/junit-${junit.version}.jar" />
<pathelement location="${lib.dir}/testng-${testng.version}.jar" />
<pathelement location="${lib.dir}/javax.servlet-api-${javax.servlet-api.version}.jar" />
<pathelement location="${lib.dir}/log4j-${log4j.version}.jar" />
<pathelement location="${lib.dir}/commons-lang3-${commons-lang3.version}.jar" />
<pathelement location="${lib.dir}/commons-io-${commons-io.version}.jar" />
<pathelement location="${lib.dir}/backport-util-concurrent-${backport-util-concurrent.version}.jar" />
<pathelement location="${lib.dir}/threetenbp-${threetenbp.version}.jar" />
<pathelement location="${lib.dir}/slf4j-api-${slf4j-api.version}.jar" />
<pathelement location="${lib.dir}/guava-${guava.version}.jar" />
<pathelement location="${lib.dir}/httpclient-cache-${httpclient-cache.version}.jar" />
<pathelement location="${lib.dir}/httpcore-${httpcore.version}.jar" />
<pathelement location="${lib.dir}/httpclient-${httpclient.version}.jar" />
<pathelement location="${lib.dir}/commons-codec-${commons-codec.version}.jar" />
<pathelement location="${lib.dir}/spring-beans-${spring-beans.version}.jar" />
<pathelement location="${lib.dir}/spring-context-${spring-context.version}.jar" />
<pathelement location="${lib.dir}/spring-tx-${spring-tx.version}.jar" />
<pathelement location="${lib.dir}/javax.persistence-${javax.persistence.version}.jar" />
<pathelement location="${lib.dir}/mockito-core-${mockito-core.version}.jar" />
<pathelement location="${lib.dir}/hamcrest-core-${hamcrest-core.version}.jar" />
<pathelement location="${lib.dir}/jena-shaded-guava-${jena-shaded-guava.version}.jar" />
<pathelement location="${lib.dir}/javax.ws.rs-api-${javax.ws.rs-api.version}.jar" />
<pathelement location="${lib.dir}/jersey-media-multipart-${jersey-media-multipart.version}.jar" />
</path>
</target>
<target name="validate_xml" depends="-init" description="validates the xml files">
<taskdef name="bug-rank-check-style" classname="text.style.check.BugRankCheckStyleTask"/>
<xmlvalidate lenient="false" failonerror="yes">
<attribute name="http://apache.org/xml/features/validation/schema" value="true" />
<attribute name="http://xml.org/sax/features/namespaces" value="true" />
<fileset dir="${etc.dir}" includes="*.xml" excludes="findbugs-exclude.xml"/>
</xmlvalidate>
<bug-rank-check-style findbugsxml="etc/findbugs.xml" failOnMissingDetector="false" />
</target>
<target name="compile" depends="-init" description="compiles java files">
<javac srcdir="${src.dir}" destdir="${main.classes.dir}" source="${javac.source}" target="${javac.target}" deprecation="${javac.deprecation}" debug="${javac.debug}" includeantruntime="false">
<classpath refid="fb-contrib.classpath" />
</javac>
</target>
<target name="compile_test" depends="compile" description="compiles java test files">
<javac srcdir="${test.dir}" destdir="${test.classes.dir}" source="${javac.source}" target="${javac.target}" deprecation="${javac.deprecation}" debug="${javac.debug}" includeantruntime="false">
<classpath refid="fb-contrib.classpath" />
<classpath refid="fb-contrib.test.classpath" />
</javac>
</target>
<target name="compile_samples" depends="-init" description="compiles sample problem files">
<javac srcdir="${samples.dir}" destdir="${samples.classes.dir}" source="1.8" target="1.8" deprecation="${javac.deprecation}" debug="${javac.debug}" includeantruntime="false">
<compilerarg value="-XDignore.symbol.file"/>
<classpath refid="fb-contrib.classpath" />
<classpath refid="fb-contrib.samples.classpath" />
</javac>
<delete file="${samples.dir}/SJVU_Sample.class" />
<javac srcdir="${samples.dir}" destdir="${samples.classes.dir}" source="1.4" target="1.4" deprecation="${javac.deprecation}" debug="${javac.debug}" includeantruntime="false">
<include name="SJVU_Sample.java" />
<classpath refid="fb-contrib.classpath" />
<classpath refid="fb-contrib.samples.classpath" />
</javac>
</target>
<target name="test" depends="compile_test" unless="no.test" description="runs unit tests">
<mkdir dir="${test_reports.dir}" />
<taskdef resource="testngtasks" classpath="${lib.dir}/testng-${testng.version}.jar"/>
<testng outputDir="${test_reports.dir}">
<classfileset dir="${test.classes.dir}" includes="**/*.class"/>
<classpath refid="fb-contrib.classpath"/>
<classpath refid="fb-contrib.test.classpath"/>
<classpath location="${test.classes.dir}"/>
</testng>
</target>
<target name="jar" depends="compile" xmlns:vcs="antlib:com.mebigfatguy.vcsversion" description="produces the fb-contrib jar file">
<vcs:vcsversion vcs="git" revisionProperty="_rev_" dateProperty="_date_" branchProperty="_branch_" urlProperty="_url_"/>
<jar destfile="${target.dir}/fb-contrib-${fb-contrib.version}.jar">
<fileset dir="etc">
<include name="findbugs.xml" />
<include name="messages*.xml" />
<include name="bugrank.txt" />
<include name="*.license" />
</fileset>
<fileset dir="${main.classes.dir}">
<include name="**/*.class" />
</fileset>
<fileset dir="${basedir}">
<include name="plugin.xml" />
<include name="license.txt" />
</fileset>
<manifest>
<attribute name="fb-contrib-version" value="${fb-contrib.version}" />
<attribute name="Main-Class" value="com.mebigfatguy.fbcontrib.FBContrib" />
<attribute name="git-url" value="${_url_}" />
<attribute name="git-branch" value="${_branch_}" />
<attribute name="git-revision" value="${_rev_}" />
<attribute name="git-date" value="${_date_}" />
<attribute name="Eclipse-RegisterBuddy" value="edu.umd.cs.findbugs.plugin.eclipse" />
<attribute name="Bundle-ManifestVersion" value="2" />
<attribute name="Bundle-Name" value="fb-contrib plugin" />
<attribute name="Bundle-SymbolicName" value="fb-contrib; singleton:=true" />
<attribute name="Bundle-Version" value="${fb-contrib.version}" />
<attribute name="Bundle-ClassPath" value="." />
<attribute name="Bundle-Vendor" value="FB-Contrib Project" />
<attribute name="Require-Bundle" value="edu.umd.cs.findbugs.plugin.eclipse" />
<attribute name="Bundle-ActivationPolicy" value="lazy" />
<attribute name="Export-Package" value="com.mebigfatguy.fbcontrib, com.mebigfatguy.fbcontrib.collect, com.mebigfatguy.fbcontrib.detect, com.mebigfatguy.fbcontrib.debug, com.mebigfatguy.fbcontrib.utils" />
<attribute name="Import-Package" value="edu.umd.cs.findbugs, edu.umd.cs.findbugs.ba, edu.umd.cs.findbugs.ba.generic, edu.umd.cs.findbugs.bcel, edu.umd.cs.findbugs.visitclass, edu.umd.cs.findbugs.internalAnnotations, org.apache.bcel, org.apache.bcel.classfile, org.apache.bcel.generic" />
</manifest>
</jar>
</target>
<target name="html" depends="-init" description="generates dynamic html">
<xslt basedir="${etc.dir}" destdir="${htdocs.dir}" style="${etc.dir}/bugdescriptions.xsl" in="${etc.dir}/messages.xml" out="${htdocs.dir}/bugdescriptions.html" />
</target>
<target name="srczip" description="builds the source distribution zip file">
<zip destfile="${target.dir}/fb-contrib-src-${fb-contrib.version}.zip">
<fileset dir="${basedir}">
<include name="**/*.java" />
<include name="**/*.xml" />
<include name="**/*.xsd" />
<include name="**/*.license" />
<include name="**/*.txt" />
<include name="**/*.md" />
<include name="**/*.xls" />
<include name="**/*.example" />
<include name="**/*.fbp" />
</fileset>
</zip>
</target>
<target name="javadoc" depends="-init" description="build the javadoc for the project">
<javadoc packagenames="com.mebigfatguy.*" sourcepath="${src.dir}" classpathref="fb-contrib.classpath" destdir="${javadoc.dir}" windowtitle="fb-contrib api" access="private">
<doctitle><![CDATA[<h1>fb-contrib javadoc</h1>]]></doctitle>
<bottom><![CDATA[<i>Copyright &#169; 2005-2017 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom>
</javadoc>
</target>
<target name="build" depends="-init, validate_xml, compile, compile_test, compile_samples, test, jar" description="builds the plugin jar">
</target>
<target name="install" depends="build" description="installs the plugin into FindBugs">
<echo message="Findbugs: ${findbugs.dir}/plugin"/>
<copy todir="${findbugs.dir}/plugin">
<fileset dir="${target.dir}">
<include name="fb-contrib-${fb-contrib.version}.jar" />
</fileset>
</copy>
</target>
<target name="sample_delta" depends="install" xmlns:fbdelta="antlib:com.mebigfatguy.fbdelta" description="compares this runs reported bugs on the sample classes set, against the stored report">
<taskdef resource="edu/umd/cs/findbugs/anttask/tasks.properties" classpath="${lib.dir}/findbugs-ant-${findbugs-ant.version}.jar"/>
<findbugs reportlevel="low" home="${findbugs.dir}" auxClassPathRef="fb-contrib.samples.classpath" output="xml:withMessages" jvmargs="-ea -Xmx800m" projectName="Samples" outputFile="${target.dir}/samples.xml">
<class location="${samples.classes.dir}" />
</findbugs>
<fbdelta:fbdelta baseReport="${basedir}/samples.xml" updateReport="${target.dir}/samples.xml" outputReport="${target.dir}/samples_delta.xml" changed="delta"/>
<antcall target="report"/>
</target>
<target name="report" if="${delta}">
<loadfile property="diff" srcFile="${target.dir}/samples_delta.xml"/>
<echo>${diff}</echo>
</target>
<target name="literals" depends="jar" xmlns:stringliterals="antlib:com.mebigfatguy.stringliterals" description="generate report of string literals used in code">
<stringliterals:stringliterals>
<classpath id="source">
<fileset dir="${main.classes.dir}">
<include name="**/*.class"/>
</fileset>
</classpath>
</stringliterals:stringliterals>
</target>
<target name="release" depends="build, srczip, html, javadoc" description="prepares everything for a release" />
<target name="sonatype" depends="release" description="prepare an artifact bundle for sonatype">
<mkdir dir="${sonatype.dir}"/>
<copy todir="${sonatype.dir}" file="${target.dir}/fb-contrib-${fb-contrib.version}.jar"/>
<copy tofile="${sonatype.dir}/fb-contrib-${fb-contrib.version}-sources.jar" file="${target.dir}/fb-contrib-src-${fb-contrib.version}.zip"/>
<jar destfile="${sonatype.dir}/fb-contrib-${fb-contrib.version}-javadoc.jar" basedir="${target.dir}" includes="javadoc/**"/>
<copy tofile="${sonatype.dir}/fb-contrib-${fb-contrib.version}.pom" file="${basedir}/pom.xml"/>
<exec executable="gpg">
<arg value="-abi" />
<arg value="${sonatype.dir}/fb-contrib-${fb-contrib.version}.jar" />
</exec>
<exec executable="gpg">
<arg value="-abi" />
<arg value="${sonatype.dir}/fb-contrib-${fb-contrib.version}.pom" />
</exec>
<exec executable="gpg">
<arg value="-abi" />
<arg value="${sonatype.dir}/fb-contrib-${fb-contrib.version}-sources.jar" />
</exec>
<exec executable="gpg">
<arg value="-abi" />
<arg value="${sonatype.dir}/fb-contrib-${fb-contrib.version}-javadoc.jar" />
</exec>
<jar destfile="${sonatype.dir}/bundle.jar" basedir="${sonatype.dir}" includes="fb-contrib*">
</jar>
<echo message="" />
<echo message="" />
<echo message="====================================================================================================================================" />
<echo message="sonatype update bundle produced at ${sonatype.dir}/bundle.jar" />
<echo message="upload this jar at https://oss.sonatype.org" />
<echo message="" />
<echo message="see link for details-> https://docs.sonatype.org/display/Repository/Uploading+3rd-party+Artifacts+to+The+Central+Repository" />
<echo message="====================================================================================================================================" />
</target>
</project>