Last active
December 20, 2016 11:49
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) | |
) | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
instead of manual String formatting in "play" you could do this:
or you could use the Fork API:
Fork.java(.....)