Does anyone have a sniffer plugin to work at work?

The maven-animal-sniffer promises plugin to tell me if my code has any links to the Java 1.6 API (or newer). This is important for those of us who are developing MacOSX Snow Leopard (which has only official 1.6), but it needs to deliver up to 1.5 environments.

Unfortunately, when I try to use it, I get all Java API calls that are reported as violations.

I am not the only person who can experience this problem, but apparently many other people will succeed.

If someone has a working POM snippet for this purpose, he will make a really useful answer.

Please note that I am trying to use the version published in central (1.4), and not one (1.2) on org.jvnet.

+2
source share
2 answers

I successfully used the following configuration for a project that was supposed to work with 1.4 JVM:

<project>
  ...
  <properties>
    <jdk.level>1.4</jdk.level>
  </properties>
  ...
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>2.0.2</version>
          <configuration>
            <source>${jdk.level}</source>
            <target>${jdk.level}</target>
          </configuration>
        </plugin>
        ...
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.jvnet</groupId>
        <artifactId>animal-sniffer</artifactId>
        <version>1.2</version>
        <executions>
          <execution>
            <id>animal-sniffer</id>
            <phase>compile</phase>
            <goals>
              <goal>check</goal>
            </goals>
            <configuration>
              <signature>
                <groupId>org.jvnet.animal-sniffer</groupId>
                <artifactId>java${jdk.level}</artifactId>
                <version>1.0</version>
              </signature>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.jvnet.animal-sniffer</groupId>
            <artifactId>java${jdk.level}</artifactId>
            <version>1.0</version>
            <type>sig</type>
          </dependency>
        </dependencies>
      </plugin>
      ...
    </plugins>
  </build>
</project>
+4
source

After fighting various versions of snake snakes and collecting bits of information related to it from here and there, I was finally able to use it =)

For a list of available signatures and their maven coordinates, see http://mojo.codehaus.org/signatures/ . There is no need to declare a dependency on a signature.

The following example shows the correct setting for the manual (check mvn clean compile animal-sniffer: check) against Java 1.5:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>animal-sniffer-maven-plugin</artifactId>
    <version>1.6</version>
    <configuration>
        <signature>
            <groupId>org.codehaus.mojo.signature</groupId>
            <artifactId>java15</artifactId>
            <version>1.0</version>
        </signature>
    </configuration>
</plugin>

, , - :

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>animal-sniffer-maven-plugin</artifactId>
    <version>1.6</version>
    <configuration>
        <signature>
            <groupId>org.codehaus.mojo.signature</groupId>
            <artifactId>java15</artifactId>
            <version>1.0</version>
        </signature>
    </configuration>
    <executions>
        <execution>
            <id>animal-sniffer</id>
            <phase>verify</phase>
            <goals>
                <goal>check</goal>
            </goals>
        </execution>
    </executions>
</plugin>
+2

All Articles