User:Chuck/Setting Up LWJGL with SBT

Intro
This guide doesn't assume you're familiar with SBT, but it isn't an introduction to SBT. For that, you should read SBT's Quick Start Guide. This guide is oriented toward unix users, though Windows users should have little problem adapting.

If you already have SBT installed, be sure you have version 0.11.2 or compatible. If not, download the SBT runner script from sbt-extras and place it somewhere in your path.

LWJGL SBT Plugin
LWJGL projects become very simple when using this plugin: you simply add the plugin, pull in its settings, and lwjgl will be added as a managed dependency. When invoking sbt run, native dependencies are taken care of behind the scenes.

A note on Slick2D
I've found the LWJGL plugin's support for Slick to be a little bit dodgy, due to Slick's problematic maven dependencies. If you're only using slick's utility or graphics classes, you can get around this by not using the slickSettings key; instead, pull in slick by hand, providing the repo and using the "intransitive" specifier. Both build definitions below use this approach.

Build Definition #1: build.sbt
 name := "myproject"

organization := "com.example"

version := "0.1.0-SNAPSHOT"

addSbtPlugin("com.github.philcali" % "sbt-lwjgl-plugin" % "3.1.1")

seq(lwjglSettings: _*)

Build Definition #2: Build.scala
A scala build is much more free-form compared to a .sbt build. The project definition below is merely a suggestion, but should be customized to the conventions used in your own scala build. Note that the filename of your build definition can be anything you want, as long as it ends in .scala: SBT builds every .scala and .sbt file it finds under project/ into your project.

project/Build.scala:  import sbt._ import Keys._

object MyBuild extends Build { val buildOrganization = "com.example" val buildVersion      = "0.1.0-SNAPSHOT" val buildScalaVersion = "2.9.1"

val rootProjectId = "myproject"

val lwjglVersion = "2.8.2"

object Settings { lazy val base = Defaults.defaultSettings ++ Seq(           organization    := buildOrganization,            version         := buildVersion,            scalaVersion    := buildScalaVersion,        ) lazy val lwjgl = LWJGLPlugin.lwjglSettings ++ Seq(           LWJGLPlugin.lwjgl.version := lwjglVersion        ) lazy val rootProject = base ++ lwjgl }

lazy val root = Project(id=rootProjectId, base=file("."), settings=Settings.rootProject) }

project/plugins.sbt:  addSbtPlugin("com.github.philcali" % "sbt-lwjgl-plugin" % "3.1.1")