Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mallman
Last active September 8, 2017 00:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mallman/5823e1a9eb5ec72b982ea93b354769e1 to your computer and use it in GitHub Desktop.
Save mallman/5823e1a9eb5ec72b982ea93b354769e1 to your computer and use it in GitHub Desktop.
SBT Ammonite integration
val ammoniteVersion = "1.0.2"
lazy val Ammonite = config("ammonite-internal").extend(Test).hide
ivyConfigurations += Ammonite
inConfig(Ammonite)(Defaults.configSettings)
resourceDirectories in Ammonite += (resourceDirectory in Test).value
fork in (Ammonite, run) := true
val log4jVersion = "2.8.2"
libraryDependencies ++= Seq(
"com.lihaoyi" % "ammonite" % ammoniteVersion % Ammonite cross CrossVersion.full,
"org.apache.logging.log4j" % "log4j-api" % log4jVersion % Ammonite,
"org.apache.logging.log4j" % "log4j-core" % log4jVersion % Ammonite,
"org.apache.logging.log4j" % "log4j-1.2-api" % log4jVersion % Ammonite,
"org.apache.logging.log4j" % "log4j-slf4j-impl" % log4jVersion % Ammonite
)
lazy val amm = inputKey[Unit]("Runs the Ammonite REPL.")
amm := { (runMain in Ammonite).partialInput(" ammonite.Main").evaluated }
outputStrategy in Ammonite := Some(StdoutOutput)
connectInput in (Ammonite, run) := true
interp.load.ivy(
"com.lihaoyi" %
s"ammonite-shell_${scala.util.Properties.versionNumberString}" %
ammonite.Constants.version
)
@
val shellSession = ammonite.shell.ShellSession()
import shellSession._
import ammonite.ops._
import ammonite.shell._
ammonite.shell.Configure(interp, repl, wd)
val localInitPath = cwd / ".amm_init.sc"
if (exists(localInitPath)) { repl.load.exec(localInitPath) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment