Conditional resolver in plugins sbt

Thirdman

I'm trying to exclude our snapshot repositories for the release build in sbt.

Therefore I thought of a environment variable or system property to control the stage I'm in, since I want to use ivy range syntax (e.g. '[1.0.0,)' ) for released versions of our own libraries and don't want to include SNAPSHOT versions of these libs. This does not compile:

resolvers += {
  val res : Seq[sbt.Resolver] = stage match {
    case "dev" => Seq("Our Artifactory snapshots2" at "https://bla/artifactory/snapshots/")
    case "release" => None
  }
  res
}

Is it possible to have conditionally added resolvers in sbt? Any advice would be appreciated. Thanks.

EDIT: I came to a solution, which is not very nice... I just add the releases a second time in the 'release' case:

resolvers += {
  val res : Seq[sbt.Resolver] = stage match {
    case "dev" => Seq("Our Artifactory snapshots2" at "https://bla/artifactory/snapshots/")
    case "release" => Seq("Our Artifactory release" at "https://bla/artifactory/releases/")
  }
  res
}

// here the releases repository is already added...
resolvers += "Our Artifactory release" at "https://bla/artifactory/releases/"
thirstycrow

You can simply write this:

resolvers ++= Seq(stage).collect {
  case "dev" => "Our Artifactory snapshots2" at "https://bla/artifactory/snapshots/"
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

All sbt plugins not found

sbt resolver for confluent platform

SBT not honouring a custom resolver

What is an SBT resolver?

SBT: plugins.sbt in subproject is ignored?

SBT: Simplest way to separate plugins.sbt

Conditional setting in SBT project

SBT plugins not using custom resolvers

GraphQl and Conditional Resolver API Requests

Redefine an sbt task conditional on a setting

sbt conditional if else style configuration

How to list active plugins in an SBT project?

How to configure sonatype nexus to allow sbt plugins?

sbteclipse: create build.sbt and plugins.sbt

Publishing an sbt artifact to the filesystem, with resolver specified in ~/.sbt/repositories file

SBT SFTP resolver not trying hard enough

Conditional settings for Gulp plugins dependent on source file

Conditional JavaAgent Command for SBT Native Packager

sbt auto-plugins - disable them but for one sub project

Is it possible to add a resolver to an SBT project's build via an AutoPlugin?

sbt jackson resolver for spark project to use maxmind databse

How do I test a change to an sbt plugin? Resolver semantics

How do I add an SBT plugin resolver on CircleCI?

Conditional Post-Build step in Jenkins (Ideally without plugins)

Can I use djangocms plugins in a conditional extended page?

Conditional dependency resolver on run-time (.net Core)

What Repository do I need to add to my Artifactory so I can get Typesafe's SBT plugins?

Why should I use front-end plugins with my sbt playframework project?

SBT Plugins: Is it possible to run scripted for a single test instead of running all tests?