The gradle scala plugin adds the compileScala
task to the project. But sometimes the scala compiler might report something like the following:
$ 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
I tried to re-run with -feature but the gradle build complained as follows:
$ 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 did not provide any useful information.
The question is, when using gradle to compile scala code, how does one pass the -feature option to the scala compiler to see the feature warnings?
EDIT
Just in case this is useful:
$ 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
Checking ScalaCompile
in the Gradle Build Language Reference leads to:
compileScala { // or: tasks.withType(ScalaCompile)
scalaCompileOptions.additionalParameters = ["-feature"]
}
By the way, scalaCompileOptions.useAnt = false
will switch from the Ant compiler to the incremental Zinc compiler, which is also used by sbt.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With