Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make compile action in an SBT subproject depend on compilation of other subprojects without adding them to classpath

Tags:

scala

sbt

For certain reasons I want to make compilation of a subproject a require compilation of b without b appearing in a's classpath. Instead, a classes will be accessed by loading them dynamically (yes, this is generally speaking a bad idea, but it is a requirement). This question was asked before for previous SBT versions, e.g. How to depend on other tasks and do your code in SBT 0.10?. I've tried

(compile in (a, Compile)) <<= (compile in (b, Compile), compile in (a, Compile)) {
  (_, out) => out
}

(based on the above answer) and

(compile in (a, Compile)) := {
  (compile in (b, Compile)).value
  (compile in (a, Compile)).value
}

Neither appears to work in SBT 0.13.9.

like image 917
Alexey Romanov Avatar asked Nov 26 '25 08:11

Alexey Romanov


1 Answers

You can use dependsOn operator to override the default compile behavior in the settings of module a.

lazy val a = Project(...)
    .settings(compile in Compile <<= compile in Compile dependsOn (compile in Compile in b))
like image 53
yahor Avatar answered Nov 29 '25 12:11

yahor