Skip to content

Instantly share code, notes, and snippets.

@olafurpg
Created February 10, 2017 14:39
Show Gist options
  • Save olafurpg/9c7cf9ddfb299d5e44d511cf99772d66 to your computer and use it in GitHub Desktop.
Save olafurpg/9c7cf9ddfb299d5e44d511cf99772d66 to your computer and use it in GitHub Desktop.
import sbt._
import Keys._
import sbt.plugins.JvmPlugin
object ScalahostPlugin extends AutoPlugin {
override def requires = JvmPlugin
override def trigger: PluginTrigger = AllRequirements
val metaVersion = "1.6.0-652.1486671053000"
val pluginJar = sys.props.get("scalahost.pluginjar")
override def projectSettings = Seq(
commands += Command.command("dumpdb") { s =>
val commands =
Project
.extract(s)
.currentProject
.aggregate
.map(x => s"${x.project}/test:compile")
println(
s"Running commands in ${}:\n" + commands.mkString("- ", "\n- ", ""))
"test:compile" :: s
},
resolvers += Resolver.bintrayIvyRepo("scalameta", "maven"),
publishMavenStyle := false, // needed for intransitive()
scalacOptions ++= {
if (scalaVersion.value.startsWith("2.10")) Nil
else {
pluginJar.map(x => s"Xplugin:$x").toList ++
List(
"-Yrangepos",
"-Xplugin-require:scalahost"
)
}
},
libraryDependencies ++= {
if (scalaVersion.value.startsWith("2.10")) Nil
else if (pluginJar.isDefined) Nil
else
compilerPlugin(
("org.scalameta" %% "scalahost" % metaVersion)
.intransitive() // avoid redundant downloads
.cross(CrossVersion.full)) ::
Nil
}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment