views:

124

answers:

1

The maven-animal-sniffer plugin promises to tell me if my code has any references to Java 1.6 (or newer) APIs. This is important to those of us who develop on MacOSX Snow Leopard (which has only an official 1.6) but need to deliver to 1.5 environments.

Sadly, when trying to use it, I get all Java API calls reported as violations.

I'm not the only person to experience this problem, but apparently plenty of other people succeed.

If someone has a working POM snippet for this purpose, it would make a really helpful answer.

Note that I'm trying to use the version published on central (1.4) not the one (1.2) back on org.jvnet.

+2  A: 

I've used the following configuration successfully for a project that had to run with a 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>
Pascal Thivent
OK, I'll try it.
bmargulies
I can't figure out what <repository/> will find this.
bmargulies
OK, got it. and it works. Whatever is wrong is wrong in the 1.4 version on central, and not here.
bmargulies
@bmargulies Good to know. But I was happy with this version.
Pascal Thivent