我想在我的配置publish
中定义Deploy
任务的自定义行为,方法是将publishTo
更改为生产服务器解析程序,并在Default
配置中保留默认解析程序以进行发布,所以我正在做以下事情:
def deploySettings = addArtifact(Artifact(projectName, "zip", "zip"), Dist.pack) ++ Seq(
publishTo := Some((publishRepo in ThisBuild).value)
)
默认publish
行为的设置(将项目发布到dev repo),我在范围deploy
中也有一个名为Deploy
的任务,publish
调用publishTo
1}} Deploy
配置中定义的设置:
private val deployConfig: Seq[Def.Setting[_]] = inConfig(Deploy) {
...
publishTo in (Deploy, publishConfiguration) <<= destination { _ map { _.resolver } },
publishConfiguration in (Deploy, publish) <<= (publishConfiguration in Deploy),
publishTo in (Deploy, publish) <<= destination { _ map { _.resolver },
...
}
但这不起作用,当我致电deploy
或deploy:publish
时,它会从*:publishTo
设置发布到dev repo,如果我不在*:publishTo
中提供deploySettings
{1}}执行崩溃:
last project/*:publishConfiguration
java.lang.RuntimeException: Repository for publishing is not specified.
at scala.sys.package$.error(package.scala:27)
at sbt.Classpaths$$anonfun$getPublishTo$1.apply(Defaults.scala:1186)
at sbt.Classpaths$$anonfun$getPublishTo$1.apply(Defaults.scala:1186)
at scala.Option.getOrElse(Option.scala:120)
at sbt.Classpaths$.getPublishTo(Defaults.scala:1186)
at sbt.Classpaths$$anonfun$57.apply(Defaults.scala:1020)
at sbt.Classpaths$$anonfun$57.apply(Defaults.scala:1020)
也许SBT尝试从默认配置中使用publishConfiguration
初始化publishTo
的问题?我应该更正为默认范围内的publish
提供不同的解析程序,为deploy:publish
提供另一个解析程序?