如何“在-source 1.5 [ERROR]中不支持解决lambda表达式".在詹金斯泊坞窗内编译时 [英] How to "solve lambda expressions are not supported in -source 1.5 [ERROR]" when compiling within a jenkins docker

查看:108
本文介绍了如何“在-source 1.5 [ERROR]中不支持解决lambda表达式".在詹金斯泊坞窗内编译时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试遵循以下詹金斯教程:

I'm trying to follow this jenkins tutorial:

https://www.youtube.com /watch?v = FonVQNqLWiE& list = PL6tu16kXT9PqIe2b0BGul-cXbmwGt7Ihw& index = 7

但是我正在尝试在dockerized jenkins中做到这一点.为此,我没有运行Windows虚拟机,而是运行了官方的jenkins docker镜像:

but I'm trying to do that within a dockerized jenkins. To do so, instead of creating a windows virtual machine, I just run the official jenkins docker image:

$ docker pull jenkins/jenkins:lts
$ docker run -P jenkins/jenkins:lts

要继续进行第6章的操作,以确保maven可用,请输入以下内容:

To follow it up to chapter #6, to make sure maven is available I enter into the container with this:

$ docker exec -it -u root amazing_bose bash

(amazing_bose是docker分配给机器的随机名称),然后在其中执行:

(amazing_bose is the random name that docker assigned to the machine) and then, inside it I do:

# apt-get update
# apt-get install maven
# which mvn
/usr/bin/mvn
# mvn --version
Apache Maven 3.3.9
Maven home: /usr/share/maven
Java version: 1.8.0_232, vendor: Oracle Corporation
Java home: /usr/local/openjdk-8/jre
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "4.9.184-linuxkit", arch: "amd64", family: "unix"

建立成功

直到第6章,一切正常.该存储库为 https://github.com/executeautomation/cucumberbasic ,编译结果在docker的jenkins中控制台的结尾为:

Build success

Until chapter #6 everything has worked fine. The repository is https://github.com/executeautomation/cucumberbasic and the compilation result in the docker's jenkins' console ends with:

Downloaded: https://repo.maven.apache.org/maven2/com/google/collections/google-collections/1.0/google-collections-1.0.jar (625 KB at 884.7 KB/sec)
[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 1 source file to /var/jenkins_home/workspace/TestJenkinsXavi/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.532 s
[INFO] Finished at: 2019-11-15T12:40:01+00:00
[INFO] Final Memory: 17M/115M
[INFO] ------------------------------------------------------------------------
Finished: SUCCESS

构建失败

相反,在第7章中,它建议为该另一个项目构建verify maven目标: https ://github.com/executeautomation/SeleniumWithCucucumber

Build failure

Instead, in chapter #7, it proposes to build the verify maven target for this other project: https://github.com/executeautomation/SeleniumWithCucucumber

在这里,在视频教程中,它可以成功编译,但是当我这样做时,我得到了这个控制台结尾:

In here, in the video tutorial it successfully compiles, but when I do it I get this console ending:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.197 s
[INFO] Finished at: 2019-11-18T08:15:03+00:00
[INFO] Final Memory: 17M/160M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project CucumberBasics: Compilation failure: Compilation failure:
[ERROR] /var/jenkins_home/workspace/TestJenkinsXavi/src/main/java/com/ea/Main.java:[73,61] lambda expressions are not supported in -source 1.5
[ERROR] (use -source 8 or higher to enable lambda expressions)
[ERROR] /var/jenkins_home/workspace/TestJenkinsXavi/src/main/java/com/ea/Main.java:[118,50] method references are not supported in -source 1.5
[ERROR] (use -source 8 or higher to enable method references)
[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目标"将构建标记为失败 完成:失败

Build step 'Invoke top-level Maven targets' marked build as failure Finished: FAILURE

所以问题是:

由于它是一个封闭的容器(jenkins/jenkins:lts),并且它不是我的源代码(来自本教程的作者),我想知道我该怎么做才能使其编译verify目标.

As it is a closed container (jenkins/jenkins:lts) and it's a source code that is not mine (it's from the tutorial's author) I wonder what do I have to do to make it compile the verify target.

推荐答案

解决方案是在Maven调用中指定源和目标JDK级别:

The solution is to specify the source and target JDK levels on the Maven invocation:

-Dmaven.compiler.source=8 -Dmaven.compiler.target=8

在Jenkins中,单击Maven构建的高级"按钮,并将这些选项添加到标有"MAVEN_OPTS"的行中.

In Jenkins, click the "Advanced" button for the Maven build and add these options to the line labelled "MAVEN_OPTS".

这篇关于如何“在-source 1.5 [ERROR]中不支持解决lambda表达式".在詹金斯泊坞窗内编译时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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