aboutsummaryrefslogtreecommitdiff
path: root/plugins/scalafix-compiler-plugin/Scalafix.scala
blob: 2a18c5db0a036fba3442954b156df4e2abd7402c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package cbt

import cbt._
import java.nio.file.Files._
import java.nio.file._
import java.io.File

trait ScalafixCompilerPlugin extends BaseBuild {
  def scalafixVersion = "0.3.1"

  override def scalacOptions = super.scalacOptions ++
   Scalafix.scalacOptions(projectDirectory.toPath,
    Resolver( mavenCentral, sonatypeReleases ).bindOne(
        ScalaDependency( "ch.epfl.scala", "scalafix-nsc", scalafixVersion )
    ).jar)
}

object Scalafix {
  def scalacOptions( rootPath: Path, nscJar: File ) =
    Seq(
      "-Xplugin:" ++ nscJar.string,
      "-Yrangepos"
    ) ++ configOption(rootPath)

  def configOption( rootPath: Path ) =
    Some( rootPath.resolve(".scalafix.conf").toAbsolutePath )
      .filter(isRegularFile(_)).map("-P:scalafix:" ++ _.toString).toSeq
}