有没有人让动物嗅探器插件起作用? [英] has anyone got the animal sniffer plugin to work?

查看:91
本文介绍了有没有人让动物嗅探器插件起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

maven-animal-sniffer插件承诺会告诉我我的代码是否具有对Java 1.6(或更高版本)API的引用.对于那些使用MacOSX Snow Leopard(仅具有官方1.6)但需要交付到1.5环境的开发人员来说,这很重要.

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.

可悲的是,当尝试使用它时,我将所有Java API调用报告为违规.

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.

如果有人为此使用了有效的POM代码段,那么它将提供非常有用的答案.

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

请注意,我正在尝试使用在Central(1.4)上发布的版本,而不是org.jvnet上的那个版本(1.2).

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

推荐答案

对于已经使用1.4 JVM运行的项目,我已经成功使用了以下配置:

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>

这篇关于有没有人让动物嗅探器插件起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆