mirror of https://github.com/sbt/sbt.git
Take into account user-supplied artifact URLs from project dependencies
Should fix the non/spire test case of https://gist.github.com/paulp/62eaca1850904137959ad9121cce6b15
This commit is contained in:
parent
6f93f85c5d
commit
8024ec7e64
|
|
@ -27,6 +27,29 @@ import scalaz.concurrent.{ Task, Strategy }
|
|||
|
||||
object Tasks {
|
||||
|
||||
def allRecursiveInterDependencies(state: sbt.State, projectRef: sbt.ProjectRef) = {
|
||||
|
||||
def dependencies(map: Map[String, Seq[String]], id: String): Set[String] = {
|
||||
|
||||
def helper(map: Map[String, Seq[String]], acc: Set[String]): Set[String] =
|
||||
if (acc.exists(map.contains)) {
|
||||
val (kept, rem) = map.partition { case (k, _) => acc(k) }
|
||||
helper(rem, acc ++ kept.valuesIterator.flatten)
|
||||
} else
|
||||
acc
|
||||
|
||||
helper(map - id, map.getOrElse(id, Nil).toSet)
|
||||
}
|
||||
|
||||
val allProjectsDeps =
|
||||
for (p <- structure(state).allProjects)
|
||||
yield p.id -> p.dependencies.map(_.project.project)
|
||||
|
||||
val deps = dependencies(allProjectsDeps.toMap, projectRef.project)
|
||||
|
||||
structure(state).allProjectRefs.filter(p => deps(p.project))
|
||||
}
|
||||
|
||||
def coursierResolversTask: Def.Initialize[sbt.Task[Seq[Resolver]]] =
|
||||
(
|
||||
externalResolvers,
|
||||
|
|
@ -52,7 +75,11 @@ object Tasks {
|
|||
sbt.Keys.thisProjectRef
|
||||
).flatMap { (state, projectRef) =>
|
||||
|
||||
val allDependenciesTask = allDependencies.in(projectRef).get(state)
|
||||
val projects = allRecursiveInterDependencies(state, projectRef)
|
||||
|
||||
val allDependenciesTask = allDependencies
|
||||
.forAllProjects(state, projectRef +: projects)
|
||||
.map(_.values.toVector.flatten)
|
||||
|
||||
for {
|
||||
allDependencies <- allDependenciesTask
|
||||
|
|
@ -103,25 +130,7 @@ object Tasks {
|
|||
sbt.Keys.thisProjectRef
|
||||
).flatMap { (state, projectRef) =>
|
||||
|
||||
def dependencies(map: Map[String, Seq[String]], id: String): Set[String] = {
|
||||
|
||||
def helper(map: Map[String, Seq[String]], acc: Set[String]): Set[String] =
|
||||
if (acc.exists(map.contains)) {
|
||||
val (kept, rem) = map.partition { case (k, _) => acc(k) }
|
||||
helper(rem, acc ++ kept.valuesIterator.flatten)
|
||||
} else
|
||||
acc
|
||||
|
||||
helper(map - id, map.getOrElse(id, Nil).toSet)
|
||||
}
|
||||
|
||||
val allProjectsDeps =
|
||||
for (p <- structure(state).allProjects)
|
||||
yield p.id -> p.dependencies.map(_.project.project)
|
||||
|
||||
val deps = dependencies(allProjectsDeps.toMap, projectRef.project)
|
||||
|
||||
val projects = structure(state).allProjectRefs.filter(p => deps(p.project))
|
||||
val projects = allRecursiveInterDependencies(state, projectRef)
|
||||
|
||||
coursierProject.forAllProjects(state, projects).map(_.values.toVector)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
case class A(msg: String)
|
||||
|
||||
object A {
|
||||
def default = A("OK")
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
|
||||
object Main extends App {
|
||||
|
||||
val msg = shapeless.Generic[A].to(A.default).head
|
||||
|
||||
Files.write(new File("output").toPath, msg.getBytes("UTF-8"))
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
lazy val a = project
|
||||
.settings(sharedSettings)
|
||||
.settings(
|
||||
libraryDependencies += "com.chuusai" %% "shapeless" % "2.3.234" from "https://oss.sonatype.org/content/repositories/releases/com/chuusai/shapeless_2.11/2.3.1/shapeless_2.11-2.3.1.jar"
|
||||
)
|
||||
|
||||
lazy val b = project
|
||||
.dependsOn(a)
|
||||
.settings(sharedSettings)
|
||||
|
||||
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