score:11
Accepted answer
I think you came really close. Here are some of the details:
- sbt downloads library dependencies and compiler plugins all using
Compile
configuration'supdate
task, which useslibraryDependencies
setting.addCompilerPlugin
is a shorthand forlibraryDependencies
withCompilerPlugin
configuration. - Compiler plugin requires
scalaOptions
on the configuration that you're interested in. - You need to grab
sources
fromCompile
to use them inLint
.
If you see the implementation of wartremoverSettings
it's doing both addCompilerPlugin
and scalacOptions
. You have two options to disable wartremover on Compile
:
- Use auto plugin (requires sbt 0.13.5+) to inject
wartremoverSettings
, then manually remove wartremover compiler plugin fromCompile
. - Disable auto plugin, then manually add wart remover into
libraryDependencies
.
Here's the first option.
project/build.properties
sbt.version=0.13.7
project/wart.sbt
addSbtPlugin("org.brianmckenna" % "sbt-wartremover" % "0.11")
build.sbt
lazy val Lint = config("lint") extend Compile
lazy val foo = project.
configs(Lint).
settings(inConfig(Lint) {
Defaults.compileSettings ++ wartremover.wartremoverSettings ++
Seq(
sources in Lint := {
val old = (sources in Lint).value
old ++ (sources in Compile).value
},
wartremover.wartremoverErrors := wartremover.Warts.all
) }: _*).
settings(
scalacOptions in Compile := (scalacOptions in Compile).value filterNot { _ contains "wartremover" }
)
foo/src/main/scala/Foo.scala
package foo
object Foo extends App {
// Won't compile: Inferred type containing Any
val any = List(1, true, "three")
println("hi")
}
sample output
foo> clean
[success] Total time: 0 s, completed Dec 23, 2014 9:43:30 PM
foo> compile
[info] Updating {file:/quick-test/wart/}foo...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Compiling 1 Scala source to /quick-test/wart/foo/target/scala-2.10/classes...
[success] Total time: 1 s, completed Dec 23, 2014 9:43:33 PM
foo> run
[info] Running foo.Foo
hi
[success] Total time: 0 s, completed Dec 23, 2014 9:43:37 PM
foo> lint:compile
[info] Compiling 1 Scala source to /quick-test/wart/foo/target/scala-2.10/lint-classes...
[error] /quick-test/wart/foo/src/main/scala/Foo.scala:5: Inferred type containing Any
[error] val any = List(1, true, "three")
[error] ^
[error] /quick-test/wart/foo/src/main/scala/Foo.scala:5: Inferred type containing Any
[error] val any = List(1, true, "three")
[error] ^
Source: stackoverflow.com
Related Query
- How can I create a separate sbt Configuration or Task to compile with WartRemover?
- How to create a separate compile task without a separate config, but different scalacOptions?
- How to run an SBT task prefixed with a configuration in batch mode?
- sbt how can I compile different configuration files
- How can I create a custom sbt task from existing tasks
- How can I make the compile task in SBT depend on a java source-processor library (spring-boot-configuration-processor)
- How to create SBT project with IntelliJ Idea?
- How to compile tests with SBT without running them
- How can I call another task from my SBT task?
- How is an sbt task defined using <<= different from one defined with := that references another setting's .value?
- How to make a sbt task use a specific configuration scope?
- How can I deploy a web app with sbt 0.11?
- How can I create a custom column type with Typesafe Slick in Scala?
- How do I create an sbt task to generate code, then include these generated managed sources in my root project?
- How can I create an instance of a Case Class with constructor arguments with no Parameters in Scala?
- How can I add jars from more than one unmanaged directory in an SBT .scala project configuration
- How to define sbt plugin task within prefix and without conflicts with global scope?
- How to create an SBT Run configuration in IntelliJ IDEA 11 Community Edition?
- How to create a generic SBT root project with varying sub projects
- How can i compile java record with scala code?
- How can I build OSGi bundles with SBT 0.10+?
- How to create a custom sbt task that sets java options before running the app
- How can i publish snapshots when using sbt with the bintray-sbt plugin?
- Can NetBeans 8.0 with Scala and sbt plugins installed create sbt project?
- How can I create an infinite Enumerator with play iteratees
- With Scala 2.10.2, SBT 0.13.0, Specs2 & Play Framework 2.2.1 how can I control logging whilst running tests?
- How can I override settings in subprojects in an SBT project with multiple subprojects
- How can create other dataframe with third column contains an array of second dataframe filtered by id of first dataframe?
- Scala Dependency Injection for compile time with separate configuration
- How to create sbt project with an android module and run with Intellij ultimate?
More Query from same tag
- Scala error handling: Try or Either?
- Extracting inner group with Scala regex
- Scala Constructor Deprecation
- Akka dispatcher configuration for io-related actors
- Can we use Google Guice DI with a Scala Object instead of a Scala class in Play 2.4 with scala
- Scala Spark - Get Overloaded method when calling createDataFrame
- How to receive binary data in a java WebSocket client
- Concise Way of Constructing Create Class with Many Fields?
- Combine 2 array elements with a separator
- scala lambda function and local variables
- Ajax call responds empty list in ScalaJS
- Scala play Guice injection
- Snake game head colliding into body scala
- Using Spark StreamingContext to Consume from Kafka topic
- Correlation Of dynamic value in Gatling
- Pass case class to Spark UDF
- Play 2.0 and MongoDB interfacing with Salat
- Checking a Scala Promise for Success
- create pairs from sets
- Alternative to load-on-startup Servlets for bootstrapping methods in an webapp
- What's the advantage of a Scala "context bound" over a normal parameter?
- Scala Play Framework, where to create actors?
- Why doesn't "((left union right) union other)" behave associatively?
- how to load activator in intellij with sbt plugin
- Gatling scenario with 10 requests per hour (less that 1 rps)
- Basic kafka topic availability checker
- json deserialize of ListBuffer[(String,String)] in play framework
- Using map on Scala with option return types
- scala: class can't access companion object members externally
- How to fix this type error, after using UDF function in Spark SQL?