以下に、mavenを使用してfindbugsNonNullアノテーションをテストするための簡単なコードを示します。
「mvncleaninstallsite」を実行すると、ディレクトリtarget / site/cssとtarget/site / imagesが取得されますが、それ以上はありません。println(null)がNonNull条件に違反しているというレポートを受け取ることを期待していました。
そのレポートを取得するには何をする必要がありますか?
また、NonNull違反がある場合に「mvncleaninstall」が成功しないようにする方法はありますか?
注:Sonarでそのようなレポートを入手できることを認識しています。ただし、このようなエラーが発生した場合は、後でオプションのSonarツールを使用せずに、「mvncleaninstall」を失敗させたいと思います。
src / main / java / test / Hello.java
package test;
import edu.umd.cs.findbugs.annotations.NonNull;
public class Hello {
    static public void print(@NonNull Object value) {
        System.out.println("value: " + value.toString());
    }
    static public void main(String[] args) {
        if (args.length > 0) {
            print(args[0]);
        } else {
            print(null);
        }
    }
}
およびpom.xmlファイル:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>hello</groupId>
  <artifactId>hello</artifactId>
  <version>1.0</version>
  <dependencies>
    <dependency>
      <groupId>net.sourceforge.findbugs</groupId>
      <artifactId>annotations</artifactId>
      <version>1.3.2</version>
    </dependency>
    <dependency>
      <groupId>net.sourceforge.findbugs</groupId>
      <artifactId>jsr305</artifactId>
      <version>1.3.7</version>
    </dependency>
  </dependencies>
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>findbugs-maven-plugin</artifactId>
        <version>2.5.2</version>
      </plugin>
    </plugins>
  </reporting>
</project>
---
更新、解決策
解決策、Augustoからの回答に基づく:プロジェクトの下のpom.xmlファイルにこれを追加します。
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>findbugs-maven-plugin</artifactId>
        <version>2.5.2</version>
        <configuration>
          <includeTests>true</includeTests>
        </configuration>
        <executions>
          <execution>
            <phase>compile</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
          <execution>
            <id>findbugs-test-compile</id>
            <phase>test-compile</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
これにより、NonNull違反がある場合、「mvncleaninstall」は失敗します。
Maven 3を使用していて、Maven 3でレポート機能が変更されたため(現在は通常のMavenプラグインを使用しているため)、レポートは機能しませんでした。