mirror of https://github.com/sbt/sbt.git
Get resolvers from inter-project dependencies too
The idea was suggested to me a few days at Scala Up North, by @MasseGuillaume or @djspiewak, IIRC Should fix a few test cases more from https://gist.github.com/paulp/62eaca1850904137959ad9121cce6b15
This commit is contained in:
parent
8024ec7e64
commit
1fcd34af8e
|
|
@ -21,6 +21,7 @@ object CoursierPlugin extends AutoPlugin {
|
|||
val mavenProfiles = Keys.mavenProfiles
|
||||
val coursierSourceRepositories = Keys.coursierSourceRepositories
|
||||
val coursierResolvers = Keys.coursierResolvers
|
||||
val coursierRecursiveResolvers = Keys.coursierRecursiveResolvers
|
||||
val coursierSbtResolvers = Keys.coursierSbtResolvers
|
||||
val coursierUseSbtCredentials = Keys.coursierUseSbtCredentials
|
||||
val coursierCredentials = Keys.coursierCredentials
|
||||
|
|
@ -68,6 +69,7 @@ object CoursierPlugin extends AutoPlugin {
|
|||
mavenProfiles := Set.empty,
|
||||
coursierSourceRepositories := Nil,
|
||||
coursierResolvers <<= Tasks.coursierResolversTask,
|
||||
coursierRecursiveResolvers <<= Tasks.coursierRecursiveResolversTask,
|
||||
coursierSbtResolvers <<= externalResolvers in updateSbtClassifiers,
|
||||
coursierUseSbtCredentials := false,
|
||||
coursierCredentials := Map.empty,
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ object Keys {
|
|||
|
||||
val coursierSourceRepositories = SettingKey[Seq[File]]("coursier-source-repositories")
|
||||
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")
|
||||
|
|
|
|||
|
|
@ -69,6 +69,19 @@ object Tasks {
|
|||
}
|
||||
}
|
||||
|
||||
def coursierRecursiveResolversTask: Def.Initialize[sbt.Task[Seq[Resolver]]] =
|
||||
(
|
||||
sbt.Keys.state,
|
||||
sbt.Keys.thisProjectRef
|
||||
).flatMap { (state, projectRef) =>
|
||||
|
||||
val projects = allRecursiveInterDependencies(state, projectRef)
|
||||
|
||||
coursierResolvers
|
||||
.forAllProjects(state, projectRef +: projects)
|
||||
.map(_.values.toVector.flatten)
|
||||
}
|
||||
|
||||
def coursierFallbackDependenciesTask: Def.Initialize[sbt.Task[Seq[(Module, String, URL, Boolean)]]] =
|
||||
(
|
||||
sbt.Keys.state,
|
||||
|
|
@ -383,7 +396,7 @@ object Tasks {
|
|||
if (sbtClassifiers)
|
||||
coursierSbtResolvers.value
|
||||
else
|
||||
coursierResolvers.value
|
||||
coursierRecursiveResolvers.value.distinct
|
||||
|
||||
val sourceRepositories = coursierSourceRepositories.value.map { dir =>
|
||||
// FIXME Don't hardcode this path?
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
case class A(msg: String)
|
||||
|
||||
object A {
|
||||
def default = A("OK")
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
|
||||
import scalaz.stream._
|
||||
import scalaz.concurrent.Task
|
||||
|
||||
object Main extends App {
|
||||
|
||||
val pch = Process.constant((i:Int) => Task.now(())).take(3)
|
||||
val count = Process.constant(1).toSource.to(pch).runLog.run.size
|
||||
assert(count == 3)
|
||||
|
||||
Files.write(new File("output").toPath, A.default.msg.getBytes("UTF-8"))
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
lazy val a = project
|
||||
.settings(sharedSettings)
|
||||
.settings(
|
||||
resolvers += "Scalaz Bintray Repo" at "https://dl.bintray.com/scalaz/releases"
|
||||
)
|
||||
|
||||
lazy val b = project
|
||||
.dependsOn(a)
|
||||
.settings(sharedSettings)
|
||||
.settings(
|
||||
// resolver added in inter-project dependency only - should still be fine
|
||||
libraryDependencies += "org.scalaz.stream" %% "scalaz-stream" % "0.7.1a"
|
||||
)
|
||||
|
||||
lazy val root = project
|
||||
.in(file("."))
|
||||
.aggregate(a, b)
|
||||
.settings(sharedSettings)
|
||||
|
||||
|
||||
lazy val sharedSettings = Seq(
|
||||
scalaVersion := "2.11.8",
|
||||
coursierCachePolicies := {
|
||||
if (sys.props("os.name").startsWith("Windows"))
|
||||
coursierCachePolicies.value
|
||||
else
|
||||
Seq(coursier.CachePolicy.ForceDownload)
|
||||
}
|
||||
)
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
val pluginVersion = sys.props.getOrElse(
|
||||
"plugin.version",
|
||||
throw new RuntimeException(
|
||||
"""|The system property 'plugin.version' is not defined.
|
||||
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin
|
||||
)
|
||||
)
|
||||
|
||||
addSbtPlugin("io.get-coursier" % "sbt-coursier" % pluginVersion)
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
$ delete output
|
||||
> b/run
|
||||
$ exists output
|
||||
Loading…
Reference in New Issue