Is it possible to add a Scala compiler plugin only when compiling test sources?
When a compiler plugin is added by calling SBT's addCompilerPlugin then a library dependency is added. The relevant methods are:
/** Transforms `dependency` to be in the auto-compiler plugin configuration. */
def compilerPlugin(dependency: ModuleID): ModuleID =
dependency.withConfigurations(Some("plugin->default(compile)"))
/** Adds `dependency` to `libraryDependencies` in the auto-compiler plugin configuration. */
def addCompilerPlugin(dependency: ModuleID): Setting[Seq[ModuleID]] =
libraryDependencies += compilerPlugin(dependency)
The question boils down if there is a withConfigurations that causes the plugin to be on the classpath only when compiling test sources. I tried Some("plugin->default(testCompile)") without success.