Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dependency missing from classpath

I have project that collects dependencies for an installer (sbt-install4j) using dependencyClasspath. It works most of the time, except when I have one specific dependency:

libraryDependencies += "org.bytedeco" % "javacpp" % "0.10"

"javacpp" will not be added to the dependencyClasspath. You can create a simple SBT project with only that dependency above and try show dependencyClasspath, it will print:

[info] List(Attributed(C:\Users\me\.sbt\boot\scala-2.10.4\lib\scala-library.jar))

there is no "javacpp". Any clues what may be happening? Is this an SBT bug?

like image 935
Jarek Avatar asked Mar 13 '15 00:03

Jarek


1 Answers

sbt excludes certain packaging types from the classpaths it generates, because not all packaging types make sense to depend on. Unfortunately, it seems to do this exclusion silently - and the default value of classpathTypes isn't always what you want.

The packaging type of the dependency can be found in the dependency's pom.xml or ivy.xml (as applicable). There are two main cases:

  1. If the packaging type is actually pom, this probably means it's a parent pom and you are trying to depend on the wrong thing - look for the specific Maven module you actually want!
  2. If on the other hand, it's maven-plugin - as in this particular case - you need to add the packaging type to classpathTypes, using: classpathTypes += "maven-plugin"

Other cases are probably going to be similar to one of the above two cases.

like image 144
Robin Green Avatar answered Sep 19 '22 17:09

Robin Green