Findbugs and annotations

FindBugs Annotations

Annotations work out the box with Findbugs as long as two dependencies are added in the compile scope of the pom.xml of your project.

Download the latest version of Findbugs http://findbugs.sourceforge.net/downloads.html and you will find in the lib directory annotations.jar and jsr305.jar

I added the two dependencies locally via :

 mvn install:install-file -DgroupId=findbugs -DartifactId=annotations -Dversion=x -Dpackaging=jar -Dfile=/tmp/findbugs-1.3.9/lib/annotations.jar
mvn install:install-file -DgroupId=findbugs -DartifactId=jcr305 -Dversion=x -Dpackaging=jar -Dfile=/tmp/findbugs-1.3.9/lib/jsr305.jar

Todo: Obviously the dependencies need to be added to the Sakai maven repository.

mvn deploy:deploy-file -DgroupId=findbugs -DartifactId=findbugs -Dversion=1.3.9 -Dfile=findbugs.jar -Dpackaging=jar -DrepositoryId=Sakai-Maven2 -Durl=dav:https://source.sakaiproject.org/maven2

OR

mvn deploy:deploy-file -DgroupId=findbugs -DartifactId=findbugs -Dversion=1.3.9 -Dfile=findbugs.jar -Dpackaging=jar -Durl=scp://source.sakaiproject.org/var/www/html/maven2   -DrepositoryId=sakai-maven2-scp

In the pom.xml

 
<dependency>
   <groupId>findbugs</groupId>
   <artifactId>annotations</artifactId>
   <version>1.3.9</version>
   <scope>compile</scope>
</dependency>
<dependency>
   <groupId>findbugs</groupId>
   <artifactId>jsr305</artifactId>
   <version>1.3.9</version>
   <scope>compile</scope>
 </dependency>

Licensing

I am not sure about the licensing implications. The license file for jsr305 is BSD and I assume annotations is part of findbugs is GPL 2.1. The Jars are not included in a running application, but support compilation.

Annotations

The possible annotations are mentioned at: http://findbugs.sourceforge.net/manual/annotations.html

Code snippet

@edu.umd.cs.findbugs.annotations.SuppressWarnings (value="EQ_ALWAYS_TRUE", justification="Deny everything")
public boolean equals(Object testObject){
     return true;
}