鉴于您所说的评论“我主要关心的是如何将任务中的 Seq[File] 结果转换为将这些文件上传到 S3 的自定义任务,并且只有在调用阶段时才调用该自定义任务。” ,答案可能如下。
您已经stage
完成了来自sbt-native-packager插件的任务。
> help stage
Create a local directory with all the files laid out as they would be in the final distribution.
您还有另一项任务,例如s3deploy
,转移resourceGenerators
到 S3。
lazy val s3deploy = taskKey[Unit]("Deploys files to S3")
s3deploy := {
println(s"Files to transfer: ${(resourceGenerators in Compile).value}")
}
这里有一个解决方案 -s3deploy
连接到stage
:
(stage in Universal) := {
val _ = s3deploy.value
(stage in Universal).value
}
全文build.sbt
如下:
import com.typesafe.sbt.packager.Keys._
packageArchetype.java_application
lazy val s3deploy = taskKey[Unit]("Deploys files to S3")
s3deploy := {
println(s"Files to transfer: ${(resourceGenerators in Compile).value}")
}
(stage in Universal) := {
val _ = s3deploy.value
(stage in Universal).value
}