检查库是否可以在特定版本的Java上运行 [英] Check if library will work on a specific verion of Java

查看:62
本文介绍了检查库是否可以在特定版本的Java上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以采用什么方法来验证库是否与特定版本的Java兼容?

What approach can be taken to verify that a library is compatible on a specific version of Java?

示例:库X是在Java 1.7上编译的,因此它可能无法在Java 1.7或更低版​​本上使用.

Example: Library X was compiled on Java 1.7, therefor it might not work on Java 1.7 or lower.

谢谢.

推荐答案

最好的方法是通过

The best is to check the byte code via an enforcer rule which can be applied to your build by using the maven-enforcer-plugin...

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>1.4.1</version>
        <executions>
          <execution>
            <id>enforce-bytecode-version</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <enforceBytecodeVersion>
                  <maxJdkVersion>1.7</maxJdkVersion>
                </enforceBytecodeVersion>
              </rules>
              <fail>true</fail>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>extra-enforcer-rules</artifactId>
            <version>1.0-beta-4</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

这篇关于检查库是否可以在特定版本的Java上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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