Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check that all Maven dependencies are compiled for Java 6

Tags:

java

maven

I am looking for a Maven-Plugin (or an other maven way) to enforce that all dependencies of a Maven project are compiled for the right java major version class file format.

Background: I am downgrading an existing project from Java 7 to Java 6, and I need to check that the libs are compiled for Java 6 (major version 50)

(Using jdk6 and hope that every library is used in at least one test, is not the solution I am looking for.)

like image 453
Ralph Avatar asked Jul 29 '14 11:07

Ralph


1 Answers

I would suggest to use the maven-enforcer-plugin in relationship with the extra-enforcer-rules for byte code version.

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>1.0</version> <!-- find the latest version at http://maven.apache.org/plugins/maven-enforcer-plugin/ -->
        <executions>
          <execution>
            <id>enforce-bytecode-version</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <enforceBytecodeVersion>
                  <maxJdkVersion>1.5</maxJdkVersion>
                  <excludes>
                    <exclude>org.mindrot:jbcrypt</exclude>
                  </excludes>
                </enforceBytecodeVersion>
              </rules>
              <fail>true</fail>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>extra-enforcer-rules</artifactId>
            <version>1.0-beta-2</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>
  [...]
</project>
like image 150
khmarbaise Avatar answered Oct 17 '22 09:10

khmarbaise