'Logging from custom SBT plugin not working

At work we've created this plugin, and from one of its inputKey it's suppose to log an exception (whenever that occurs). For demonstration purposes I've only used the relevant stuff, so have a look at the following code:

theTask := {
  streams.value.log
  val args: Seq[String] = spaceDelimited("<arg>").parsed
  args.foreach { arg =>
    val env = SomeLogicThatPotentiallyThrowsException(arg)
  }
}
object SomeLogicThatPotentiallyThrowsException {
  def apply(arg: String): String = {
    if(arg==throwexception) throw Exception("Boom!")
    else arg
  }
}

so whenever I'm trying to use the plugin and execute the task as follows:

sbt theTask throwexception

The error is only logged whenever I've added streams.value.log as a statement in the theTask task..

So yeah.. am I doing anything wrong here or is this a bug in sbt?

Thanks for reading people



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source