mirror of https://github.com/sbt/sbt.git
Move resolvers related tasks to sbt-coursier-shared
So that they can be used from sbt-lm-coursier too
This commit is contained in:
parent
a592ee587a
commit
ff79cab75c
|
|
@ -1,7 +1,7 @@
|
|||
package coursier.sbtcoursier
|
||||
package coursier.sbtcoursiershared
|
||||
|
||||
import coursier.lmcoursier._
|
||||
import coursier.sbtcoursier.Keys._
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport._
|
||||
import coursier.sbtcoursiershared.Structure._
|
||||
import sbt.{Classpaths, Def}
|
||||
import sbt.Keys._
|
||||
|
|
@ -2,8 +2,9 @@ package coursier.sbtcoursiershared
|
|||
|
||||
import coursier.core.{Configuration, Project, Publication}
|
||||
import coursier.lmcoursier.SbtCoursierCache
|
||||
import sbt.{AutoPlugin, Compile, Setting, TaskKey, Test, settingKey}
|
||||
import sbt.{AutoPlugin, Compile, Setting, TaskKey, Test, settingKey, taskKey}
|
||||
import sbt.Keys.{classpathTypes, clean}
|
||||
import sbt.librarymanagement.Resolver
|
||||
|
||||
object SbtCoursierShared extends AutoPlugin {
|
||||
|
||||
|
|
@ -16,6 +17,13 @@ object SbtCoursierShared extends AutoPlugin {
|
|||
val coursierProject = TaskKey[Project]("coursier-project")
|
||||
val coursierInterProjectDependencies = TaskKey[Seq[Project]]("coursier-inter-project-dependencies", "Projects the current project depends on, possibly transitively")
|
||||
val coursierPublications = TaskKey[Seq[(Configuration, Publication)]]("coursier-publications")
|
||||
|
||||
val coursierKeepPreloaded = settingKey[Boolean]("Whether to take into account sbt preloaded repositories or not")
|
||||
val coursierReorderResolvers = settingKey[Boolean](
|
||||
"Whether resolvers should be re-ordered so that typically slow ones are given a lower priority"
|
||||
)
|
||||
val coursierResolvers = taskKey[Seq[Resolver]]("")
|
||||
val coursierRecursiveResolvers = taskKey[Seq[Resolver]]("Resolvers of the current project, plus those of all from its inter-dependency projects")
|
||||
}
|
||||
|
||||
import autoImport._
|
||||
|
|
@ -23,7 +31,15 @@ object SbtCoursierShared extends AutoPlugin {
|
|||
def publicationsSetting(packageConfigs: Seq[(sbt.Configuration, Configuration)]): Setting[_] =
|
||||
coursierPublications := ArtifactsTasks.coursierPublicationsTask(packageConfigs: _*).value
|
||||
|
||||
override def projectSettings =
|
||||
override def buildSettings: Seq[Setting[_]] =
|
||||
Seq(
|
||||
coursierReorderResolvers := true,
|
||||
coursierKeepPreloaded := false
|
||||
)
|
||||
|
||||
override def projectSettings = settings(pubSettings = true)
|
||||
|
||||
def settings(pubSettings: Boolean) =
|
||||
Seq[Setting[_]](
|
||||
clean := {
|
||||
val noWarningPlz = clean.value
|
||||
|
|
@ -31,12 +47,25 @@ object SbtCoursierShared extends AutoPlugin {
|
|||
},
|
||||
coursierGenerateIvyXml := true,
|
||||
coursierProject := InputsTasks.coursierProjectTask.value,
|
||||
coursierInterProjectDependencies := InputsTasks.coursierInterProjectDependenciesTask.value,
|
||||
publicationsSetting(Seq(Compile, Test).map(c => c -> Configuration(c.name))),
|
||||
coursierInterProjectDependencies := InputsTasks.coursierInterProjectDependenciesTask.value
|
||||
) ++ {
|
||||
if (pubSettings)
|
||||
Seq(
|
||||
publicationsSetting(Seq(Compile, Test).map(c => c -> Configuration(c.name)))
|
||||
)
|
||||
else
|
||||
Nil
|
||||
} ++ Seq(
|
||||
// Tests artifacts from Maven repositories are given this type.
|
||||
// Adding it here so that these work straightaway.
|
||||
classpathTypes += "test-jar"
|
||||
) ++
|
||||
IvyXml.generateIvyXmlSettings()
|
||||
classpathTypes += "test-jar", // FIXME Should this go in buildSettings?
|
||||
coursierResolvers := RepositoriesTasks.coursierResolversTask.value,
|
||||
coursierRecursiveResolvers := RepositoriesTasks.coursierRecursiveResolversTask.value,
|
||||
) ++ {
|
||||
if (pubSettings)
|
||||
IvyXml.generateIvyXmlSettings()
|
||||
else
|
||||
Nil
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,12 +21,8 @@ object CoursierPlugin extends AutoPlugin {
|
|||
val coursierArtifactsChecksums = Keys.coursierArtifactsChecksums
|
||||
val coursierCachePolicies = Keys.coursierCachePolicies
|
||||
val coursierTtl = Keys.coursierTtl
|
||||
val coursierKeepPreloaded = Keys.coursierKeepPreloaded
|
||||
val coursierVerbosity = Keys.coursierVerbosity
|
||||
val mavenProfiles = Keys.mavenProfiles
|
||||
val coursierResolvers = Keys.coursierResolvers
|
||||
val coursierReorderResolvers = Keys.coursierReorderResolvers
|
||||
val coursierRecursiveResolvers = Keys.coursierRecursiveResolvers
|
||||
val coursierSbtResolvers = Keys.coursierSbtResolvers
|
||||
val coursierUseSbtCredentials = Keys.coursierUseSbtCredentials
|
||||
val coursierCredentials = Keys.coursierCredentials
|
||||
|
|
@ -147,8 +143,6 @@ object CoursierPlugin extends AutoPlugin {
|
|||
def coursierSettings(
|
||||
shadedConfigOpt: Option[(String, Configuration)] = None
|
||||
): Seq[Setting[_]] = hackHack ++ Seq(
|
||||
coursierResolvers := RepositoriesTasks.coursierResolversTask.value,
|
||||
coursierRecursiveResolvers := RepositoriesTasks.coursierRecursiveResolversTask.value,
|
||||
coursierSbtResolvers := {
|
||||
|
||||
// TODO Add docker-based integration test for that, see https://github.com/coursier/coursier/issues/632
|
||||
|
|
@ -173,7 +167,7 @@ object CoursierPlugin extends AutoPlugin {
|
|||
else
|
||||
resolvers
|
||||
|
||||
if (coursierKeepPreloaded.value)
|
||||
if (SbtCoursierShared.autoImport.coursierKeepPreloaded.value)
|
||||
resolvers0
|
||||
else
|
||||
resolvers0.filter { r =>
|
||||
|
|
@ -280,8 +274,6 @@ object CoursierPlugin extends AutoPlugin {
|
|||
coursierUseSbtCredentials := true,
|
||||
coursierCredentials := Map.empty,
|
||||
coursierCache := Cache.default,
|
||||
coursierReorderResolvers := true,
|
||||
coursierKeepPreloaded := false,
|
||||
coursierCreateLogger := { () => new TermDisplay(new OutputStreamWriter(System.err)) }
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -17,19 +17,12 @@ object Keys {
|
|||
val coursierArtifactsChecksums = SettingKey[Seq[Option[String]]]("coursier-artifacts-checksums")
|
||||
val coursierCachePolicies = SettingKey[Seq[CachePolicy]]("coursier-cache-policies")
|
||||
val coursierTtl = SettingKey[Option[Duration]]("coursier-ttl")
|
||||
val coursierKeepPreloaded = SettingKey[Boolean]("coursier-keep-preloaded", "Whether to take into account sbt preloaded repositories or not")
|
||||
val coursierCreateLogger = TaskKey[() => Cache.Logger]("coursier-create-logger")
|
||||
|
||||
val coursierVerbosity = SettingKey[Int]("coursier-verbosity")
|
||||
|
||||
val mavenProfiles = SettingKey[Set[String]]("maven-profiles")
|
||||
|
||||
val coursierReorderResolvers = SettingKey[Boolean](
|
||||
"coursier-reorder-resolvers",
|
||||
"Whether resolvers should be re-ordered so that typically slow ones are given a lower priority"
|
||||
)
|
||||
val coursierResolvers = TaskKey[Seq[Resolver]]("coursier-resolvers")
|
||||
val coursierRecursiveResolvers = TaskKey[Seq[Resolver]]("coursier-recursive-resolvers", "Resolvers of the current project, plus those of all from its inter-dependency projects")
|
||||
val coursierSbtResolvers = TaskKey[Seq[Resolver]]("coursier-sbt-resolvers")
|
||||
val coursierUseSbtCredentials = SettingKey[Boolean]("coursier-use-sbt-credentials")
|
||||
val coursierCredentials = TaskKey[Map[String, Credentials]]("coursier-credentials")
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ object ShadingPlugin extends AutoPlugin {
|
|||
sbt.Classpaths.ivyBaseSettings ++
|
||||
sbt.Classpaths.ivyPublishSettings ++
|
||||
shadingJvmPublishSettings ++
|
||||
SbtCoursierShared.settings(pubSettings = false) ++
|
||||
CoursierPlugin.coursierSettings(
|
||||
Some(baseDependencyConfiguration.value -> Configuration(Shaded.name))
|
||||
) ++
|
||||
|
|
@ -107,7 +108,7 @@ object ShadingPlugin extends AutoPlugin {
|
|||
configuration := baseSbtConfiguration, // wuw
|
||||
ivyConfigurations := ivyConfigurations.in(baseSbtConfiguration).value
|
||||
.filter(_.name != Shaded.name)
|
||||
.map(c => c.withExtendsConfigs(c.extendsConfigs.toVector.filter(_.name != Shaded.name))),
|
||||
.map(c => c.withExtendsConfigs(c.extendsConfigs.filter(_.name != Shaded.name))),
|
||||
libraryDependencies := libraryDependencies.in(baseSbtConfiguration).value.filter { dep =>
|
||||
val isShaded = dep.configurations.exists { mappings =>
|
||||
ivyXmlMappings(mappings).exists(_._1 == Configuration(Shaded.name))
|
||||
|
|
|
|||
Loading…
Reference in New Issue