Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #123

Closed
wants to merge 1 commit into from
Closed

Update README.md #123

wants to merge 1 commit into from

Conversation

ahsandar
Copy link

Added the additional library dependencies required to use JavaCV in a SBT based project

Added the additional library dependencies required to use JavaCV in a SBT based project
@saudet
Copy link
Member

saudet commented Apr 13, 2015 via email

@jpsacha
Copy link
Member

jpsacha commented Apr 14, 2015

Platform, like linux-x86, can be determined automatically using code shown here. Maybe worth creating a simple SBT plugin to avoid cutting and pasting, it is 19 lines :)

@saudet
Copy link
Member

saudet commented Apr 14, 2015

@jpsacha Instead of that code, do you know if it is possible with sbt to call Loader.getPlatform() directly as a "maven-plugin"? With Maven, AFAIK, it's not possible, but if we can with sbt, it could help provide a nicer workaround.

@jpsacha
Copy link
Member

jpsacha commented Apr 14, 2015

SBT can call anything that can be added to its classpath, so it could be possible to call Loader.getPlatform() that way. Not sure if it can access a "maven-plugin", will need to check on that.

@jpsacha
Copy link
Member

jpsacha commented Apr 14, 2015

@saudet What exactly javacpp "maven-plugin" do?

@saudet
Copy link
Member

saudet commented Apr 14, 2015

I'm not sure myself, maybe nothing. sbt seems to treat "jar" artifacts differently from "maven-plugin" ones, unlike Maven itself. It's just a keyword required to indicate to Maven to look up for classes implementing the Mojo interface, which is BuildMojo in JavaCPP's case.

@jpsacha
Copy link
Member

jpsacha commented Apr 15, 2015

I modified javacv-examples to use javacpp to determine platform in build.sbt:

val platform = org.bytedeco.javacpp.Loader.getPlatform

To make it work javacpp needs to be added to build.sbt classpath. It is done in project/plugins.sbt:

classpathTypes += "maven-plugin"
libraryDependencies += "org.bytedeco" % "javacpp" % "0.11"

@saudet
Copy link
Member

saudet commented Apr 15, 2015

Great 👍 Thanks! BTW, do you know if it's possible to get the dependencies of JavaCV so we can loop over that and add the platform specific dependencies as well?

@jpsacha
Copy link
Member

jpsacha commented Apr 15, 2015

If you just want to add dependency on specific preset libraries you could use in build.sbt som ething like this:

// Platform classifier for native library dependencies
val platform = org.bytedeco.javacpp.Loader.getPlatform
// Libraries with native dependencies
val bytedecoPresetLibs = Seq(
  // library names and versions
  "opencv" -> "2.4.11-0.11",
  "flycapture" -> "2.7.3.19-0.11"
).flatMap { case (lib, ver) =>
  Seq(
    // Add both: dependency and its native binaries for the current `platform`
    "org.bytedeco.javacpp-presets" % lib % ver,
    "org.bytedeco.javacpp-presets" % lib % ver classifier platform
  )
}

libraryDependencies ++= Seq(
  "org.bytedeco" % "javacpp" % javacppVersion,
  "org.bytedeco" % "javacv" % javacppVersion,
  "org.scala-lang.modules" %% "scala-swing" % "1.0.1",
  "junit" % "junit" % "4.12" % "test",
  "com.novocode" % "junit-interface" % "0.11" % "test"
) ++ bytedecoPresetLibs

It is also possible to automatically determine all "org.bytedeco.javacpp-presets" libraries from "javacv" dependencies and add platform classifier to each. I will need to think how to actually do it. Though that will possibly add large amount of unneeded dependencies to the project.

@saudet
Copy link
Member

saudet commented Apr 15, 2015

Yes, I realize it would add a lot of unneeded dependencies. I am just hoping to have something like that as a sample build file, because we can't do it the Maven way. :) There is no hurry, so take your time! Thanks

@saudet
Copy link
Member

saudet commented Nov 3, 2015

Hi, any updates on this?

@ahsandar
Copy link
Author

ahsandar commented Nov 3, 2015

not yet , haven't had time to work on it yet

@saudet saudet mentioned this pull request Mar 7, 2016
@saudet
Copy link
Member

saudet commented Apr 1, 2017

Closing as this is no longer required with the "platform artifacts". We just need to add a dependency on "javacv-platform" or "opencv-platform", for example, which in turn depend on binaries for all platforms. This works not only with Maven, but with Gradle and sbt as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants