Skip to content

Commit

Permalink
Add a method to help manage JavaCPP presets
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydmeta committed Mar 7, 2016
1 parent 28e8781 commit 92d7748
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
22 changes: 22 additions & 0 deletions README.markdown
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
@@ -1,6 +1,6 @@
name := """sbt-javacpp"""

version := "1.0"
version := "1.1-SNAPSHOT"

organization := "com.beachape"

Expand Down
14 changes: 14 additions & 0 deletions src/main/scala/com/beachape/sbt/javacpp/Plugin.scala
Expand Up @@ -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
)
}
}

}

0 comments on commit 92d7748

Please sign in to comment.