我正在更新fm-sbt-s3-resolver
中具有sbt plugin
的{{1}}。在明确添加所需设置作为问题的副作用方面,我已经取得了一些进展:
SettingKey
当我尝试使用object MyPlugin {
override def requires = S3ResolverPlugin
override def trigger = allRequirements
override lazy val globalSettings = Seq(
resolvers ++= repos,
publishMavenStyle := true,
S3ResolverPlugin.autoImport.s3CredentialsProvider := {bucket: String =>
new AWSCredentialsProviderChain(
new EnvironmentVariableCredentialsProvider(),
PropertyFilesCredentialProvider.create(bucket, streams.value.log)
)
}
)
}
添加logging
时,sbt会引发错误:
streams.value.log
答案 0 :(得分:0)
在这种情况下,您需要依赖设置sLog
而不是任务streams
。
import sbt._
import sbt.Keys._
object Logs extends AutoPlugin {
object autoImport {
val settingLog = settingKey[Unit]("Uses setting sLog")
val taskLog = taskKey[Unit]("Uses task streams log")
}
import autoImport._
override def trigger = allRequirements
override def projectSettings: Seq[Def.Setting[_]] = Seq(
settingLog := { sLog.value.info("Logging on settings execution") },
taskLog := { streams.value.log.info("Logging on task execution") }
)
}
与settingLog
的不同之处在于它将在sbt启动时记录。
~/w/t/stackoverflow $ sbt
[info] Logging on settings execution
对settingLog
的重复调用将不再产生任何日志记录。但是taskLog
会在您每次调用日志时打印日志