I use the s3 resolver plugin for sbt.
I have changed the credentials provider:
lazy val s3CredentialsProvider = {bucket: String =>
new AWSCred
This is a way of adding logging to classes that you defined for your AutoPlugin
import sbt._
import sbt.Keys._
object TestPlugin extends AutoPlugin {
class SomeClassThatNeedsLogger(logger: Logger) {
def doSomeLogging(): Unit = {
logger.info("It logs")
}
}
object autoImport {
val someClassThatNeedsLoggerHolder = taskKey[SomeClassThatNeedsLogger]("Holds instance of SomeClassThatNeedsLogger")
val runSomeClassThatNeedsLogger = taskKey[Unit]("Runs SomeClassThatNeedsLogger")
}
import autoImport._
override def trigger = allRequirements
override def projectSettings: Seq[Def.Setting[_]] = {
Seq(
someClassThatNeedsLoggerHolder := new SomeClassThatNeedsLogger(streams.value.log),
runSomeClassThatNeedsLogger := someClassThatNeedsLoggerHolder.value.doSomeLogging()
)
}
}
And running gives us a log entry:
> runSomeClassThatNeedsLogger
[info] It logs
[success] Total time: 0 s, completed Feb 6, 2019 9:47:15 AM
Some notes on errors you're getting
value
can only be called on a task within a task definition macro,
such as :=, +=, ++=, or Def.task.
This tells you that streams.value
can be used only in task definitions like someClassThatNeedsLoggerHolder := new SomeClassThatNeedsLogger(streams.value.log)
ConsoleLogger using sbt.util.internal
As the package name suggests, this is an internal package and subject to a change in next versions of sbt. It should not be used in your plugin definitions.