Alexey Romanov
Alexey Romanov

Reputation: 170805

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

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.

Upvotes: 3

Views: 334

Answers (1)

yahor
yahor

Reputation: 401

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))

Upvotes: 1

Related Questions