Override publishTo in publishConfiguration in custom configuration

Viewed 1118

I want to define custom behavior of publish task in my configuration Deploy, by changing publishTo to production server resolver and leave default resolver for publish in Default config, so i'm doing the following:

def deploySettings = addArtifact(Artifact(projectName, "zip", "zip"), Dist.pack) ++ Seq(
  publishTo := Some((publishRepo in ThisBuild).value)
)

This settings for default publish behavior (publish project to dev repo) and i also have a task called deploy in scope Deploy, which calls publish with publishTo setting defined in Deploy configuration:

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 },
  ...
}

But this doesn't work and when i call deploy or deploy:publish it publishes to dev repo from *:publishTo settings and if i won't provide *:publishTo in deploySettings execution crashes with:

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)

Maybe the problem that SBT tryies to init publishConfiguration with publishTo from default configs? What should i correct to provide different resolver for publish in default scope and another one for deploy:publish?

0 Answers
Related