Skip to content

Instantly share code, notes, and snippets.

@jmhofer
Last active December 20, 2016 11:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jmhofer/2260897 to your computer and use it in GitHub Desktop.
Save jmhofer/2260897 to your computer and use it in GitHub Desktop.
SBT build for Scalatron (see also https://github.com/jmhofer/scalatron-bot.g8)
// copy all jars from Scalatron's distribution (bin directory) into lib/
lazy val botDirectory = settingKey[File]("bot-directory")
lazy val play = taskKey[Int]("Plays a game of Scalatron, returns the exit code upon completion.")
lazy val Versions = new {
lazy val Specs2 = "3.8.6"
}
lazy val root = (project in file(".")).settings(
inThisBuild(Seq(
organization := "de.johoop",
scalaVersion := "2.12.1",
scalacOptions ++= Seq("-encoding", "UTF8", "-deprecation", "-unchecked"),
scalacOptions in Test += "-Yrangepos"
)),
name := "scalatron-bot",
libraryDependencies += "org.specs2" %% "specs2-core" % Versions.Specs2 % Test,
botDirectory := file("bots"),
javaOptions += "-Xmx1g",
play := {
val bots = botDirectory.value
val ucp = (unmanagedClasspath in Compile).value
val botJar = (Keys.`package` in Compile).value
IO createDirectory (bots / name.value)
IO copyFile (botJar, bots / name.value / "ScalatronBot.jar")
Fork.java(
config = ForkOptions(
runJVMOptions = javaOptions.value ++ Seq("-cp", (ucp.files :+ botJar).absString)
),
arguments = Seq("scalatron.main.Main", "-plugins", bots.absolutePath)
)
}
)
@jmhofer
Copy link
Author

jmhofer commented Dec 20, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment