Skip to content

Instantly share code, notes, and snippets.

@retronym
Created September 26, 2018 23:14
Show Gist options
  • Save retronym/1969e361157a17b73608862991dec3a8 to your computer and use it in GitHub Desktop.
Save retronym/1969e361157a17b73608862991dec3a8 to your computer and use it in GitHub Desktop.
package io.github.retronym
import sbt._
import Keys._
object RawCompile extends AutoPlugin {
override def trigger = allRequirements
override def requires = sbt.plugins.JvmPlugin
val compileRaw = taskKey[Unit]("Compile directly, bypassing the incremental compiler")
val cleanClasses = taskKey[Unit]("clean the classes directory")
override lazy val projectSettings = List(Compile, Test).flatMap(c => inConfig(c)(Seq(
addCompileRaw,
cleanClasses := IO.delete(classDirectory.value)
)))
def addCompileRaw = compileRaw := {
val compiler = new sbt.compiler.RawCompiler(scalaInstance.value, sbt.ClasspathOptions.auto, streams.value.log)
classDirectory.value.mkdirs()
compiler.apply(sources.value, classDirectory.value +: dependencyClasspath.value.map(_.data), classDirectory.value, scalacOptions.value)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment