Skip to content

Instantly share code, notes, and snippets.

@trygvis
Created March 31, 2012 15:51
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 trygvis/2266342 to your computer and use it in GitHub Desktop.
Save trygvis/2266342 to your computer and use it in GitHub Desktop.
An improved sbt build file for Scalatron
// Based off http://jmhofer.johoop.de/?p=292 / https://gist.github.com/2260897
// Put this file under project/Build.scala
// Copy Scalatron/bin/Scalatron.jar to lib/ before compiling
// Tested with sbt version 0.11.2
import sbt._
import Keys._
object Build extends Build {
val botDirectory = SettingKey[File]("bot-directory")
val play = TaskKey[Unit]("play") <<= (botDirectory, name, javaOptions,
unmanagedClasspath in Compile,
Keys.`package` in Compile) map {
(bots, name, javaOptions, ucp, botJar) =>
IO createDirectory (bots / name)
IO copyFile (botJar, bots / name / "ScalatronBot.jar")
val cmd = "java %s -cp %s scalatron.main.Main -plugins %s" format (
javaOptions mkString " ",
Seq(ucp.files.head, botJar).absString,
bots.absolutePath)
cmd run
}
val bot = Project(
id = "mybot",
base = file("."),
settings = Project.defaultSettings ++ botSettings)
val botSettings = Seq[Setting[_]](
organization := "com.example.foo",
name := "my-scalatron-bot",
version := "1.0-SNAPSHOT",
scalaVersion := "2.9.1",
scalacOptions ++= Seq("-deprecation", "-unchecked"),
javaOptions += "-Xmx1g",
libraryDependencies ++= Seq(
"org.specs2" %% "specs2" % "1.8.2" % "test",
"org.pegdown" % "pegdown" % "1.0.2" % "test",
"junit" % "junit" % "4.7" % "test"),
testOptions := Seq(
Tests.Filter(_ == "de.johoop.scalatron.BotSpec"),
Tests.Argument("html", "console")),
testOptions <+= crossTarget map { ct =>
Tests.Setup { () =>
System.setProperty("specs2.outDir",
new File(ct, "specs2").getAbsolutePath)
}
},
botDirectory := file("bots"),
play)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment