-
In a pretty simple build definition, I was trying to override the import mill._
import scalalib._
object core extends ScalaModule {
def scalaVersion = "2.13.11"
object test extends ScalaTests with TestModule.ScalaTest {
def other = T {
T.log.info("Other log")
}
def test(args: String*) = T.command {
other()
T.log.info("Running test")
super.test()
}
}
}
whereas if I defined another target, with the same signature, it works fine: def mytest(args: String*) = T.command {
T.log.info("test")
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The issue with your attempt is, that you don't depend on the result of the def test(args: String*) = T.command {
other()
T.log.info("Running test")
- super.test()
+ super.test()()
} As To use a task's outcome, you always add one addition parenthesis pair more than on the definition side. |
Beta Was this translation helpful? Give feedback.
The issue with your attempt is, that you don't depend on the result of the
super.test()
command, but instead return the command itself. Or in other words, you forgot the second()
.As
T.command
accepts aTask
and you already return a task, you essentially return thatsuper.test
task and also access theT.log.info
outside of a task, which is not possible. Hence, the somewhat unhelpful error message.To use a task's outcome, you always add one addition parenthesis pair more than on the definition side.
This is the short for
task.apply()
. For commands, that…