Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sbt dependsOn % "compile->compile;test->test"

Tags:

scala

sbt

I've been trying to understand what "compile->compile;test->test" is for, but after reading in sbt page still I don't understand it ...

Let's say I have this in build.sbt

lazy val `api` = project.dependsOn(`domain` % "compile->compile;test->test")
...
lazy val `domain` = project...

What's the difference if I remove "compile->compile;test->test"

lazy val `api` = project.dependsOn(`domain`)
...
lazy val `domain` = project...

What if I only put "test->test"? Or "compile->compile"?

like image 576
M.G. Avatar asked Oct 26 '25 05:10

M.G.


1 Answers

Useful commands to see what is going on are

show api / Test / dependencyClasspath
show api / Compile / dependencyClasspath

which will reveal the exact classpaths.

if I remove "compile->compile;test->test"

lazy val api = project.dependsOn(domain)

is equivalent to

lazy val api = project.dependsOn(domain % "compile->compile")

and means api / Compile configuration depends on domain / Compile. If you execute show api / Test / dependencyClasspath then you should see domain's test classpath is not present.

What if I only put "test->test"?

lazy val api = project.dependsOn(domain % "test->test")

means api / Test depends on domain / Test and executing show api / Test / dependencyClasspath should reveal domain's test classpath being present. However executing show api / Compile / dependencyClasspath should reveal domain's compile classpath not being present.

Hence if you want api / Test to depend on domain / Test, and api / Compile to depend on domain / Compile, then you have to specify

lazy val api = project.dependsOn(domain % "compile->compile;test->test")
like image 109
Mario Galic Avatar answered Oct 28 '25 23:10

Mario Galic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!