'jvm-1.8'不是'-target'的有效选择 [英] 'jvm-1.8' is not a valid choice for '-target'

查看:1660
本文介绍了'jvm-1.8'不是'-target'的有效选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 错误:scalac:'jvm-1.8'当我试图做我的项目时,IntelliJ抱怨出现以下异常。不是'-target'的有效选择
错误:scalac:错误的选项:'-target:jvm-1.8'

但'gradlew clean install'工作得很好。



项目设置为:

gradle版本2.3

scala 2.10和java

这4个模块中的3个使用java 1.7(源和目标兼容性),第4个模块具有源和目标兼容性1.8,问题。



任何想法如何避免错误? (移动到java 7不是一个选项,升级scala是)

解决方案

Gradle默认使用ant任务构建Scala代码,以及 https://issues.scala-lang.org/browse/SI-8966显示jvm 1.8在Scala 2.11.5之前并未作为支持的目标添加。



您可以尝试使用基于锌的编译器,并添加以下gradle build文件。

  tasks.withType(ScalaCompile){
scalaCompileOptions.useAnt = false
}

您可能还需要将锌编译器添加到您的依赖列表中。


IntelliJ complains with the following exception when I try to make my project.

Error:scalac: 'jvm-1.8' is not a valid choice for '-target'
Error:scalac: bad option: '-target:jvm-1.8'

But a 'gradlew clean install' works just fine.

The project setup is:

gradle version 2.3

scala 2.10 and java

3 of the 4 modules use java 1.7 (source and target compatibility), the 4th module has source and target compatibility 1.8 and is causing the problem.

Any ideas how I can avoid the error? (moving to java 7 is not an option, upgrading scala is)

解决方案

Gradle by default use the ant task to build Scala code, and https://issues.scala-lang.org/browse/SI-8966 shows that jvm 1.8 was not added as a supported target until Scala 2.11.5.

You can try using the Zinc based compiler with by adding the following the gradle build file.

    tasks.withType(ScalaCompile) {
      scalaCompileOptions.useAnt = false
    }

You may also need to add the zinc compiler to your dependency list.

这篇关于'jvm-1.8'不是'-target'的有效选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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