Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SBT: how to include both ordinary jar and test-jar of same dependency

Tags:

maven

scala

sbt

In my SBT descriptor I have:

libraryDependencies ++= Seq(
  "org.neo4j" % "neo4j-kernel" % neo4jVersion,
  "org.neo4j" % "neo4j-kernel" % neo4jVersion % "test" classifier "tests" // test-jar
)

With this setup I don't get test-jar dependency (second line). But if I remove the first line, than test-jar dependency is in place.

How to include both dependencies?

like image 242
Tvaroh Avatar asked Dec 07 '13 22:12

Tvaroh


1 Answers

Are you trying to get test-jar available for your main ("compile") code? Or for your test code?

As per http://www.scala-sbt.org/release/docs/Detailed-Topics/Library-Management.html#ivy-configurations , if you're trying to get the test config of something else available for your main code, you'll need something like % "compile->test" (my 'compile' uses their 'test').

e.g. if you wanted both in main,

"org.neo4j" % "neo4j-kernel" % neo4jVersion
"org.neo4j" % "neo4j-kernel" % neo4jVersion classifier "tests" % "compile->test"

or if you just want the latter in test, try shuffling the order of classifier and % "test" maybe?

"org.neo4j" % "neo4j-kernel" % neo4jVersion
"org.neo4j" % "neo4j-kernel" % neo4jVersion classifier "tests" % "test"

Do paste show compile:dependencyClasspath vs show test:dependencyClasspath (at the sbt prompt)

like image 52
Rob Starling Avatar answered Oct 08 '22 01:10

Rob Starling