Created
February 12, 2014 04:29
-
-
Save richdougherty/8950062 to your computer and use it in GitHub Desktop.
Using native libraries in Play
This file contains hidden or 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
| 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.")) | |
| } | |
| } |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| # 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