diff --git a/README.markdown b/README.markdown index e2dd604..5d26f7f 100644 --- a/README.markdown +++ b/README.markdown @@ -10,6 +10,28 @@ In your `project/plugins.sbt`: addSbtPlugin("com.beachape" % "sbt-javacpp" % "1.0") ``` +If you want to add a dependency on a JavaCPP preset in your project, the following will do that for you, taking care +of adding the proper preset for your target platform as well: + +```scala +// in build.sbt +import import com.beachape.sbt.javacpp.{ Plugin => JavaCppPlugin } + +JavaCppPlugin.javaCppPresetDependency("opencv") +``` + +## Customisation + +By default, this plugin will download the appropriate binaries for the platform of the computer currently +running SBT, you can modify this by setting it to another platform (for example, if you want to compile JARs to be run +on other platforms) + +```scala +javaCppPlatform := "android-arm" +``` + +Alternatively, you can set the target platform by passing a System Property: `sbt.javacpp.platform` + ## Licence The MIT License (MIT) diff --git a/build.sbt b/build.sbt index 24e3d05..4a572ca 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ name := """sbt-javacpp""" -version := "1.0" +version := "1.1-SNAPSHOT" organization := "com.beachape" diff --git a/src/main/scala/com/beachape/sbt/javacpp/Plugin.scala b/src/main/scala/com/beachape/sbt/javacpp/Plugin.scala index decb573..e288f00 100644 --- a/src/main/scala/com/beachape/sbt/javacpp/Plugin.scala +++ b/src/main/scala/com/beachape/sbt/javacpp/Plugin.scala @@ -35,4 +35,18 @@ object Plugin extends AutoPlugin { override def trigger: PluginTrigger = allRequirements + /** + * Given the name of a JavaCpp preset library, appends the proper preset native wrapper dependencies (according to the javaCppPlatform setting) + */ + def javaCppPresetDependency(javaCppPresetLib: String): Def.Setting[Seq[ModuleID]] = { + import autoImport._ + libraryDependencies <++= (javaCppPlatform, javaCppVersion, javaCppPresetsVersion) { + (resolvedJavaCppPlatform, resolvedJavaCppVersion, resolvedJavaCppPresetsVersion) => + Seq( + "org.bytedeco.javacpp-presets" % javaCppPresetLib % s"$resolvedJavaCppPresetsVersion-$resolvedJavaCppVersion" classifier "", + "org.bytedeco.javacpp-presets" % javaCppPresetLib % s"$resolvedJavaCppPresetsVersion-$resolvedJavaCppVersion" classifier resolvedJavaCppPlatform + ) + } + } + } \ No newline at end of file