【问题标题】:re-run with -feature for details, How to see scala feature warnings when building with gradle?使用 -feature 重新运行以获取详细信息,使用 gradle 构建时如何查看 scala 功能警告?
【发布时间】:2014-07-18 04:45:18
【问题描述】:

gradle scala 插件将compileScala 任务添加到项目中。但有时 scala 编译器可能会报告如下内容:

$ gradle compileScala 
:compileJava UP-TO-DATE 
:compileScala 
[ant:scalac] warning: there were 3 feature warning(s); re-run with -feature for details     
[ant:scalac] one warning found

BUILD SUCCESSFUL

Total time: 21.796 secs

我尝试使用 -feature 重新运行,但 gradle 构建抱怨如下:

$ gradle compileScala -feature

FAILURE: Build failed with an exception.

* What went wrong:
Problem configuring task :compileScala from command line.
> Unknown command-line option '-f'.

* Try:
Run gradle help --task :compileScala to get task usage details. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 4.792 secs

gradle help --task :compileScala 没有提供任何有用的信息。

问题是,当使用 gradle 编译 scala 代码时,如何将 -feature 选项传递给 scala 编译器以查看功能警告?

编辑

以防万一这有用:

$ gradle --version

------------------------------------------------------------
Gradle 1.12
------------------------------------------------------------

Build time:   2014-04-29 09:24:31 UTC
Build number: none
Revision:     a831fa866d46cbee94e61a09af15f9dd95987421

Groovy:       1.8.6
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
Ivy:          2.2.0
JVM:          1.7.0_55 (Oracle Corporation 24.55-b03)
OS:           Linux 3.13.0-27-generic amd64

$ scala -version
Scala code runner version 2.10.3 -- Copyright 2002-2013, LAMP/EPFL

【问题讨论】:

    标签: scala build gradle scalac


    【解决方案1】:

    Gradle Build Language Reference 中检查ScalaCompile 会导致:

    compileScala { // or: tasks.withType(ScalaCompile)
        scalaCompileOptions.additionalParameters = ["-feature"]
    }
    

    顺便说一句,scalaCompileOptions.useAnt = false 会从 Ant 编译器切换到增量 Zinc 编译器,sbt 也使用这个编译器。

    【讨论】:

      猜你喜欢
      • 2015-03-09
      • 2014-07-18
      • 1970-01-01
      • 2018-05-23
      • 1970-01-01
      • 2012-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多