Travis CI JDK设置为oraclejdk8,但得到的错误表明源代码是1.5



我在运行Travis CI时遇到了一些困难。我以为我的.yml文件被正确地设置为使用java8,但我收到的错误表明情况并非如此。

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=192m; support was removed in 8.0
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T17:29:23+00:00)
Maven home: /usr/local/maven
Java version: 1.8.0_31, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-042stab105.14", arch: "amd64", family: "unix"
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building HonestMistakesWPINav 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ HonestMistakesWPINav ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 7 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ HonestMistakesWPINav ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 24 source files to /home/travis/build/theflanman/HonestMistakesWPINav/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/travis/build/theflanman/HonestMistakesWPINav/src/main/gui/DevGUIFront.java:[214,92] lambda expressions are not supported in -source 1.5
  (use -source 8 or higher to enable lambda expressions)
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.506 s
[INFO] Finished at: 2015-11-24T18:19:53+00:00
[INFO] Final Memory: 9M/134M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project HonestMistakesWPINav: Compilation failure
[ERROR] /home/travis/build/theflanman/HonestMistakesWPINav/src/main/gui/DevGUIFront.java:[214,92] lambda expressions are not supported in -source 1.5
[ERROR] (use -source 8 or higher to enable lambda expressions)
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

据我所知,maven已经意识到我使用的是java8,但travis是用1.5编译的。我找不到任何关于如何改变这一点的东西,任何帮助都将不胜感激。

您的travis.yml是什么样子的?

这是我的前三行,这对我来说很好(我用的是gradle而不是maven)

language: java
jdk:
  - oraclejdk8

你必须为任何人提供更多的信息来帮助解决这个问题。

作为参考,这是我的全部travis.yml供参考。

我解决了在.travis.yml文件中添加这两行的类似问题:

install: mvn install -Dmaven.compiler.target=1.8 -Dmaven.compiler.source=1.8 -DskipTests=true
script: mvn test -Dmaven.compiler.target=1.8 -Dmaven.compiler.source=1.8

或者,您可以通过POM.xml:指示编译过程中使用的JDK版本

    <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
        </configuration>
    </plugin>

这两种方法都适用于我。

最新更新