mirror of https://github.com/sbt/sbt.git
add includePluginResolvers
Fixes #5070 This adds a new setting called `includePluginResolvers` (default `false`). When set to `true`, it the project will include resolvers from the metabuild. This allows the build user to declare a resolver in one place (`project/plugins.sbt`) that gets applied to both the metabuild as well as all the subprojects. The scenario comes up when someone distributes a software on their own repo. Ref #4103
This commit is contained in:
parent
d119818656
commit
6664cbe2ae
|
|
@ -2174,6 +2174,7 @@ object Classpaths {
|
||||||
moduleConfigurations :== Nil,
|
moduleConfigurations :== Nil,
|
||||||
publishTo :== None,
|
publishTo :== None,
|
||||||
resolvers :== Vector.empty,
|
resolvers :== Vector.empty,
|
||||||
|
includePluginResolvers :== false,
|
||||||
useJCenter :== false,
|
useJCenter :== false,
|
||||||
retrievePattern :== Resolver.defaultRetrievePattern,
|
retrievePattern :== Resolver.defaultRetrievePattern,
|
||||||
transitiveClassifiers :== Seq(SourceClassifier, DocClassifier),
|
transitiveClassifiers :== Seq(SourceClassifier, DocClassifier),
|
||||||
|
|
@ -2246,10 +2247,21 @@ object Classpaths {
|
||||||
(Def.task {
|
(Def.task {
|
||||||
val proj = projectResolver.value
|
val proj = projectResolver.value
|
||||||
val rs = externalResolvers.value
|
val rs = externalResolvers.value
|
||||||
|
def pluginResolvers: Vector[Resolver] =
|
||||||
|
buildStructure.value
|
||||||
|
.units(thisProjectRef.value.build)
|
||||||
|
.unit
|
||||||
|
.plugins
|
||||||
|
.pluginData
|
||||||
|
.resolvers
|
||||||
|
.getOrElse(Vector.empty)
|
||||||
|
val pr =
|
||||||
|
if (includePluginResolvers.value) pluginResolvers
|
||||||
|
else Vector.empty
|
||||||
bootResolvers.value match {
|
bootResolvers.value match {
|
||||||
case Some(repos) if overrideBuildResolvers.value => proj +: repos
|
case Some(repos) if overrideBuildResolvers.value => proj +: repos
|
||||||
case _ =>
|
case _ =>
|
||||||
val base = if (sbtPlugin.value) sbtResolvers.value ++ rs else rs
|
val base = if (sbtPlugin.value) sbtResolvers.value ++ rs ++ pr else rs ++ pr
|
||||||
(proj +: base).distinct
|
(proj +: base).distinct
|
||||||
}
|
}
|
||||||
}).value,
|
}).value,
|
||||||
|
|
|
||||||
|
|
@ -411,7 +411,8 @@ object Keys {
|
||||||
val fullResolvers = taskKey[Seq[Resolver]]("Combines the project resolver, default resolvers, and user-defined resolvers.").withRank(CTask)
|
val fullResolvers = taskKey[Seq[Resolver]]("Combines the project resolver, default resolvers, and user-defined resolvers.").withRank(CTask)
|
||||||
val otherResolvers = taskKey[Seq[Resolver]]("Resolvers not included in the main resolver chain, such as those in module configurations.").withRank(CSetting)
|
val otherResolvers = taskKey[Seq[Resolver]]("Resolvers not included in the main resolver chain, such as those in module configurations.").withRank(CSetting)
|
||||||
val scalaCompilerBridgeResolvers = taskKey[Seq[Resolver]]("Resolvers used to resolve compiler bridges.").withRank(CSetting)
|
val scalaCompilerBridgeResolvers = taskKey[Seq[Resolver]]("Resolvers used to resolve compiler bridges.").withRank(CSetting)
|
||||||
val useJCenter = settingKey[Boolean]("Use JCenter as the default repository.").withRank(BSetting)
|
val includePluginResolvers = settingKey[Boolean]("Include the resolvers from the metabuild.").withRank(CSetting)
|
||||||
|
val useJCenter = settingKey[Boolean]("Use JCenter as the default repository.").withRank(CSetting)
|
||||||
val moduleConfigurations = settingKey[Seq[ModuleConfiguration]]("Defines module configurations, which override resolvers on a per-module basis.").withRank(BMinusSetting)
|
val moduleConfigurations = settingKey[Seq[ModuleConfiguration]]("Defines module configurations, which override resolvers on a per-module basis.").withRank(BMinusSetting)
|
||||||
val retrievePattern = settingKey[String]("Pattern used to retrieve managed dependencies to the current build.").withRank(DSetting)
|
val retrievePattern = settingKey[String]("Pattern used to retrieve managed dependencies to the current build.").withRank(DSetting)
|
||||||
val retrieveConfiguration = settingKey[Option[RetrieveConfiguration]]("Configures retrieving dependencies to the current build.").withRank(DSetting)
|
val retrieveConfiguration = settingKey[Option[RetrieveConfiguration]]("Configures retrieving dependencies to the current build.").withRank(DSetting)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
lazy val check = taskKey[Unit]("")
|
||||||
|
ThisBuild / includePluginResolvers := true
|
||||||
|
|
||||||
|
check := {
|
||||||
|
val rs = fullResolvers.value
|
||||||
|
assert(rs exists (_.name == "bintray-eed3si9n-sbt-plugins"), s"$rs does not include bintray")
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
resolvers += Resolver.bintrayRepo("eed3si9n", "sbt-plugins")
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
> check
|
||||||
Loading…
Reference in New Issue