Skip to content

Instantly share code, notes, and snippets.

@richdougherty
Created February 12, 2014 04:29
Show Gist options
  • Select an option

  • Save richdougherty/8950062 to your computer and use it in GitHub Desktop.

Select an option

Save richdougherty/8950062 to your computer and use it in GitHub Desktop.
Using native libraries in Play
package controllers
import play.api._
import play.api.mvc._
import com.almworks.sqlite4java._
import java.io.File
object Application extends Controller {
def index = Action {
val db = new SQLiteConnection(new File("/tmp/database"))
db.open(true)
db.dispose()
Ok(views.html.index("Your new application is ready."))
}
}
name := "native"
version := "1.0-SNAPSHOT"
libraryDependencies ++= Seq(
"com.almworks.sqlite4java" % "sqlite4java" % "0.282",
"com.almworks.sqlite4java" % "libsqlite4java-osx" % "0.282" artifacts(Artifact("libsqlite4java-osx", "jnilib", "jnilib"))
)
classpathTypes ++= Set("jnilib", "dll")
play.Project.playScalaSettings
# COMMAND TO LAUNCH
PLAY_OPTS="-Djava.library.path=$PLAY_HOME/repository/cache/com.almworks.sqlite4java/libsqlite4java-osx/jnilibs" $PLAY_HOME/play start
# COMMAND TO DIST
$PLAY_HOME/play dist
# EXTRACT AND REPAIR DISTRIBUTION --
unzip target/universal/native-1.0-SNAPSHOT.zip
cd native-1.0-SNAPSHOT
mv lib/com.almworks.sqlite4java.libsqlite4java-osx-0.282.jar lib/libsqlite4java-osx.jnilib
# RUN DISTRIBUTION --
bin/native -Djava.library.path=lib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment