How can I force maven to package my project against 1.5?

前端 未结 2 1549
温柔的废话
温柔的废话 2020-12-17 20:02

I am trying to compile a maven project, the source code uses Generics and other featuers of Java 1.5, thus causing my build to fail

In my POM.xml I have

相关标签:
2条回答
  • 2020-12-17 20:38

    You have to set some properties to compile with java 1.5

    <properties>
        <!-- maven-compiler-plugin configuration -->
        <maven.compiler.source>1.5</maven.compiler.source>
        <maven.compiler.target>1.5</maven.compiler.target>
    </properties>
    
    0 讨论(0)
  • 2020-12-17 20:55

    You configured the assembly-plugin with some information about source/target but to configure the compiling you need to configure the compiler-plugin in the correct way.

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>2.3.1</version>
      <configuration>
        <source>1.5</source>
        <target>1.5</target>
      </configuration>
    </plugin>
    

    Update: This should be combined with maven-enforcer-plugin to force really using of JDK 1.5 instead of only using source/target option of the javac.

    0 讨论(0)
提交回复
热议问题