Commits

Anonymous committed 437abde

Adding support to run findbugs reports.

  • Participants
  • Parent commits b636091

Comments (0)

Files changed (29)

     <target name="generate-all-coverage-reports" depends="-init">
         <subant target="coverage-report" buildpath="${cobertura.modules}" inheritrefs="false" inheritall="false"/>
     </target>
+    <target name="scanbugs" depends="-init" description="Runs code analysis tools to detect bug patterns.">
+        <subant target="scanbugs" buildpath="${cobertura.modules}" inheritrefs="false" inheritall="false"/>
+      <!--<repeat target="scanbugs-in-module" name="module.name" values="${allmodules}"/>-->
+    </target>
+  
 </project>
 <project name="org.netbeans.modules.android.core" default="netbeans" basedir=".">
     <description>Builds, tests, and runs the project org.netbeans.modules.android.core.</description>
     <import file="nbproject/build-impl.xml"/>
+    <import file="${suite.dir}/tools/code-analysis.xml"/>
 </project>

grammars/build.xml

 <project name="org.netbeans.modules.android.grammars" default="netbeans" basedir=".">
     <description>Builds, tests, and runs the project org.netbeans.modules.android.grammars.</description>
     <import file="nbproject/build-impl.xml"/>
+    <import file="${suite.dir}/tools/code-analysis.xml"/>
 </project>
+mockito: used for testing
+findbugs: stripped version (just libs) used to run code analysis in continuous build
+

libs/findbugs-1.3.9/lib/annotations.jar

Binary file added.

libs/findbugs-1.3.9/lib/ant.jar

Binary file added.

libs/findbugs-1.3.9/lib/asm-3.1.jar

Binary file added.

libs/findbugs-1.3.9/lib/asm-analysis-3.1.jar

Binary file added.

libs/findbugs-1.3.9/lib/asm-commons-3.1.jar

Binary file added.

libs/findbugs-1.3.9/lib/asm-tree-3.1.jar

Binary file added.

libs/findbugs-1.3.9/lib/asm-util-3.1.jar

Binary file added.

libs/findbugs-1.3.9/lib/asm-xml-3.1.jar

Binary file added.

libs/findbugs-1.3.9/lib/bcel.jar

Binary file added.

libs/findbugs-1.3.9/lib/buggy.icns

Binary file added.

libs/findbugs-1.3.9/lib/commons-lang-2.4.jar

Binary file added.

libs/findbugs-1.3.9/lib/dom4j-1.6.1.jar

Binary file added.

libs/findbugs-1.3.9/lib/findbugs-ant.jar

Binary file added.

libs/findbugs-1.3.9/lib/findbugs.jar

Binary file added.

libs/findbugs-1.3.9/lib/jFormatString.jar

Binary file added.

libs/findbugs-1.3.9/lib/jaxen-1.1.1.jar

Binary file added.

libs/findbugs-1.3.9/lib/jdepend-2.9.jar

Binary file added.

libs/findbugs-1.3.9/lib/jsr305.jar

Binary file added.

libs/findbugs-1.3.9/lib/mysql-connector-java-5.1.7-bin.jar

Binary file added.
 <project name="org.nyerel.nbandroid.logcat" default="netbeans" basedir=".">
     <description>Builds, tests, and runs the project logcat</description>
     <import file="nbproject/build-impl.xml"/>
+    <import file="${suite.dir}/tools/code-analysis.xml"/>
 </project>

nbproject/project.properties

     ${project.org.netbeans.modules.android.core}:\
     ${project.org.netbeans.modules.android.logcat}:\
     ${project.org.netbeans.modules.android.project}:\
+    ${project.org.netbeans.modules.android.testrunner69}:\
     ${project.org.netbeans.modules.android.xml}:\
     ${project.org.netbeans.modules.android.grammars}

project/build.xml

 -->
  <project name="android/project" default="netbeans" basedir=".">
     <import file="nbproject/build-impl.xml"/>
+    <import file="${suite.dir}/tools/code-analysis.xml"/>
 </project>

testrunner69/build.xml

 <project name="org.netbeans.modules.android.testrunner69" default="netbeans" basedir=".">
     <description>Builds, tests, and runs the project org.netbeans.modules.android.testrunner69.</description>
     <import file="nbproject/build-impl.xml"/>
+    <import file="${suite.dir}/tools/code-analysis.xml"/>
     
     <target name="nbm" depends="projectized-common.nbm" description="Build NBM archive.">
       <echoproperties/>

tools/code-analysis.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<project name="code-analysis" basedir="." default="scanbugs">
+
+  <!-- targets to perform various checks for bug patterns -->
+  <target name="scanbugs" depends="init,find_srcpath,set_srcpath,check-findbugs,run-findbugs"
+          description="Runs various code analysis tools">
+    <echo message="Scanning module ${code.name.base} for bug patterns"/>
+  
+  <!--
+    <ant dir="${nb_all}/libs/external" target="unscramble"/>
+    <mkdir dir="tmp"/>
+    <unzip src="${nb_all}/libs/external/pmd-netbeans35-bin-0.91.zip" dest="tmp">
+        <patternset>
+            <include name="pmd.nbm"/>
+        </patternset>
+    </unzip>
+    <unzip src="tmp/pmd.nbm" dest="tmp">
+        <patternset>
+            <include name="**/*.jar"/>
+        </patternset>
+    </unzip>
+    <path id="pmd-cp">
+      <pathelement location="tmp/netbeans/modules/ext/jakarta-oro-2.0.jar"/>
+      <pathelement location="tmp/netbeans/modules/ext/jaxen-core-1.0-fcs.jar"/>
+      <pathelement location="tmp/netbeans/modules/ext/saxpath-1.0-fcs.jar"/>
+      <pathelement location="tmp/netbeans/modules/ext/pmd-1.3.jar"/>
+    </path>
+    <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmd-cp"/>
+    
+    <tempfile property="temp.file" />
+    <echo file="${temp.file}" message="output.name=pmd_${module.name}.html"/>
+    <replace file="${temp.file}" token="/" value="_"/>
+    <property file="${temp.file}"/>
+    <delete file="${temp.file}"/>
+    <echo message="using output ${output.name}"/>
+    <property name="pmd.rules" value="rulesets/strings.xml,rulesets/basic.xml,rulesets/unusedcode.xml,rulesets/design.xml,rulesets/imports.xml,rulesets/coupling.xml,rulesets/strictexception.xml"/>
+    <pmd rulesetfiles="${pmd.rules}"
+         shortfilenames="true">
+        <formatter type="html" toFile="${nb_all}/nbbuild/${output.name}"/>
+        <fileset refid="src.files"/>
+        <fileset refid="libsrc.files"/>
+    </pmd>-->
+    <!--<delete dir="tmp"/>-->
+
+  </target>
+  
+  <target name="find_srcpath">
+    <!--<echoproperties destfile="findbugs.properties"/>-->
+    <!-- TODO how to deal with libsrc/antsrc -->
+    
+    <!-- define as empty and redefine if the dir exists -->
+    <fileset id="src.files" dir=".">
+      <include name=""/>
+    </fileset>
+  </target>
+  <target name="set_srcpath" if="src.dir">
+    <fileset id="src.files" dir="${src.dir}">
+      <include name="**/*.java"/>
+    </fileset>
+  </target>
+  
+  <target name="check-findbugs">
+    <!-- sets property for modules that are projectized and if the findbugs is avalable -->
+    <property name="findbugs.home" value="${suite.dir}/libs/findbugs-1.3.9" />
+    <path id="fb-cp">
+      <pathelement location="${findbugs.home}/lib/findbugs.jar"/>
+      <pathelement location="${findbugs.home}/lib/findbugs-ant.jar"/>
+      <pathelement location="${findbugs.home}/lib/bcel.jar"/>
+      <pathelement location="${findbugs.home}/lib/dom4j-1.6.1.jar"/>
+    </path>
+    
+    <echo message="module.jar ${module.jar}" level="verbose"/>
+    <available property="aaa" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="fb-cp"/>
+    <echo message="aaa ${aaa}" level="verbose"/>
+        
+    <condition property="run.findbugs">
+      <and>
+        <available classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="fb-cp"/>
+        <available file="${cluster}/${module.jar}"/>
+      </and>
+    </condition>
+  </target>
+  
+  <target name="run-findbugs" if="run.findbugs">
+    <echo message="Running findbugs for module ${code.name.base}"/>
+    <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="fb-cp"/>
+    
+    <property name="outputfb.name" value="${build.dir}/findbugs_${code.name.base.dashes}.xml"/>
+    <echo message="using output ${outputfb.name}"/>
+    <path id="src.path">
+      <fileset refid="src.files"/>
+    </path>
+    <findbugs home="${findbugs.home}"
+              output="xml"
+              outputFile="${outputfb.name}" >
+      <auxClasspath path="${module.run.classpath}"/>
+      <sourcePath refid="src.path" />
+      <class location="${cluster}/${module.jar}" />
+    </findbugs>
+  </target>
+</project>
 <project name="org.netbeans.modules.android.xml" default="netbeans" basedir=".">
     <description>Builds, tests, and runs the project org.netbeans.modules.android.xml.</description>
     <import file="nbproject/build-impl.xml"/>
+    <import file="${suite.dir}/tools/code-analysis.xml"/>
 </project>