mirror of https://github.com/sbt/sbt.git
Handle explicit URLs from sbt-lm-coursier
This commit is contained in:
parent
0289895584
commit
da2c0f5f1f
|
|
@ -14,22 +14,23 @@ final class CoursierConfiguration private (
|
|||
val sbtScalaVersion: Option[String],
|
||||
val sbtScalaJars: Vector[java.io.File],
|
||||
val interProjectDependencies: Vector[coursier.core.Project],
|
||||
val excludeDependencies: Vector[(String, String)]) extends Serializable {
|
||||
val excludeDependencies: Vector[(String, String)],
|
||||
val fallbackDependencies: Vector[coursier.lmcoursier.FallbackDependency]) extends Serializable {
|
||||
|
||||
private def this() = this(None, sbt.librarymanagement.Resolver.defaults, true, 6, 100, None, None, Vector.empty, Vector.empty, Vector.empty)
|
||||
private def this() = this(None, sbt.librarymanagement.Resolver.defaults, true, 6, 100, None, None, Vector.empty, Vector.empty, Vector.empty, Vector.empty)
|
||||
|
||||
override def equals(o: Any): Boolean = o match {
|
||||
case x: CoursierConfiguration => (this.log == x.log) && (this.resolvers == x.resolvers) && (this.reorderResolvers == x.reorderResolvers) && (this.parallelDownloads == x.parallelDownloads) && (this.maxIterations == x.maxIterations) && (this.sbtScalaOrganization == x.sbtScalaOrganization) && (this.sbtScalaVersion == x.sbtScalaVersion) && (this.sbtScalaJars == x.sbtScalaJars) && (this.interProjectDependencies == x.interProjectDependencies) && (this.excludeDependencies == x.excludeDependencies)
|
||||
case x: CoursierConfiguration => (this.log == x.log) && (this.resolvers == x.resolvers) && (this.reorderResolvers == x.reorderResolvers) && (this.parallelDownloads == x.parallelDownloads) && (this.maxIterations == x.maxIterations) && (this.sbtScalaOrganization == x.sbtScalaOrganization) && (this.sbtScalaVersion == x.sbtScalaVersion) && (this.sbtScalaJars == x.sbtScalaJars) && (this.interProjectDependencies == x.interProjectDependencies) && (this.excludeDependencies == x.excludeDependencies) && (this.fallbackDependencies == x.fallbackDependencies)
|
||||
case _ => false
|
||||
}
|
||||
override def hashCode: Int = {
|
||||
37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (17 + "coursier.lmcoursier.CoursierConfiguration".##) + log.##) + resolvers.##) + reorderResolvers.##) + parallelDownloads.##) + maxIterations.##) + sbtScalaOrganization.##) + sbtScalaVersion.##) + sbtScalaJars.##) + interProjectDependencies.##) + excludeDependencies.##)
|
||||
37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (17 + "coursier.lmcoursier.CoursierConfiguration".##) + log.##) + resolvers.##) + reorderResolvers.##) + parallelDownloads.##) + maxIterations.##) + sbtScalaOrganization.##) + sbtScalaVersion.##) + sbtScalaJars.##) + interProjectDependencies.##) + excludeDependencies.##) + fallbackDependencies.##)
|
||||
}
|
||||
override def toString: String = {
|
||||
"CoursierConfiguration(" + log + ", " + resolvers + ", " + reorderResolvers + ", " + parallelDownloads + ", " + maxIterations + ", " + sbtScalaOrganization + ", " + sbtScalaVersion + ", " + sbtScalaJars + ", " + interProjectDependencies + ", " + excludeDependencies + ")"
|
||||
"CoursierConfiguration(" + log + ", " + resolvers + ", " + reorderResolvers + ", " + parallelDownloads + ", " + maxIterations + ", " + sbtScalaOrganization + ", " + sbtScalaVersion + ", " + sbtScalaJars + ", " + interProjectDependencies + ", " + excludeDependencies + ", " + fallbackDependencies + ")"
|
||||
}
|
||||
private[this] def copy(log: Option[xsbti.Logger] = log, resolvers: Vector[sbt.librarymanagement.Resolver] = resolvers, reorderResolvers: Boolean = reorderResolvers, parallelDownloads: Int = parallelDownloads, maxIterations: Int = maxIterations, sbtScalaOrganization: Option[String] = sbtScalaOrganization, sbtScalaVersion: Option[String] = sbtScalaVersion, sbtScalaJars: Vector[java.io.File] = sbtScalaJars, interProjectDependencies: Vector[coursier.core.Project] = interProjectDependencies, excludeDependencies: Vector[(String, String)] = excludeDependencies): CoursierConfiguration = {
|
||||
new CoursierConfiguration(log, resolvers, reorderResolvers, parallelDownloads, maxIterations, sbtScalaOrganization, sbtScalaVersion, sbtScalaJars, interProjectDependencies, excludeDependencies)
|
||||
private[this] def copy(log: Option[xsbti.Logger] = log, resolvers: Vector[sbt.librarymanagement.Resolver] = resolvers, reorderResolvers: Boolean = reorderResolvers, parallelDownloads: Int = parallelDownloads, maxIterations: Int = maxIterations, sbtScalaOrganization: Option[String] = sbtScalaOrganization, sbtScalaVersion: Option[String] = sbtScalaVersion, sbtScalaJars: Vector[java.io.File] = sbtScalaJars, interProjectDependencies: Vector[coursier.core.Project] = interProjectDependencies, excludeDependencies: Vector[(String, String)] = excludeDependencies, fallbackDependencies: Vector[coursier.lmcoursier.FallbackDependency] = fallbackDependencies): CoursierConfiguration = {
|
||||
new CoursierConfiguration(log, resolvers, reorderResolvers, parallelDownloads, maxIterations, sbtScalaOrganization, sbtScalaVersion, sbtScalaJars, interProjectDependencies, excludeDependencies, fallbackDependencies)
|
||||
}
|
||||
def withLog(log: Option[xsbti.Logger]): CoursierConfiguration = {
|
||||
copy(log = log)
|
||||
|
|
@ -70,10 +71,13 @@ final class CoursierConfiguration private (
|
|||
def withExcludeDependencies(excludeDependencies: Vector[(String, String)]): CoursierConfiguration = {
|
||||
copy(excludeDependencies = excludeDependencies)
|
||||
}
|
||||
def withFallbackDependencies(fallbackDependencies: Vector[coursier.lmcoursier.FallbackDependency]): CoursierConfiguration = {
|
||||
copy(fallbackDependencies = fallbackDependencies)
|
||||
}
|
||||
}
|
||||
object CoursierConfiguration {
|
||||
|
||||
def apply(): CoursierConfiguration = new CoursierConfiguration()
|
||||
def apply(log: Option[xsbti.Logger], resolvers: Vector[sbt.librarymanagement.Resolver], reorderResolvers: Boolean, parallelDownloads: Int, maxIterations: Int, sbtScalaOrganization: Option[String], sbtScalaVersion: Option[String], sbtScalaJars: Vector[java.io.File], interProjectDependencies: Vector[coursier.core.Project], excludeDependencies: Vector[(String, String)]): CoursierConfiguration = new CoursierConfiguration(log, resolvers, reorderResolvers, parallelDownloads, maxIterations, sbtScalaOrganization, sbtScalaVersion, sbtScalaJars, interProjectDependencies, excludeDependencies)
|
||||
def apply(log: xsbti.Logger, resolvers: Vector[sbt.librarymanagement.Resolver], reorderResolvers: Boolean, parallelDownloads: Int, maxIterations: Int, sbtScalaOrganization: String, sbtScalaVersion: String, sbtScalaJars: Vector[java.io.File], interProjectDependencies: Vector[coursier.core.Project], excludeDependencies: Vector[(String, String)]): CoursierConfiguration = new CoursierConfiguration(Option(log), resolvers, reorderResolvers, parallelDownloads, maxIterations, Option(sbtScalaOrganization), Option(sbtScalaVersion), sbtScalaJars, interProjectDependencies, excludeDependencies)
|
||||
def apply(log: Option[xsbti.Logger], resolvers: Vector[sbt.librarymanagement.Resolver], reorderResolvers: Boolean, parallelDownloads: Int, maxIterations: Int, sbtScalaOrganization: Option[String], sbtScalaVersion: Option[String], sbtScalaJars: Vector[java.io.File], interProjectDependencies: Vector[coursier.core.Project], excludeDependencies: Vector[(String, String)], fallbackDependencies: Vector[coursier.lmcoursier.FallbackDependency]): CoursierConfiguration = new CoursierConfiguration(log, resolvers, reorderResolvers, parallelDownloads, maxIterations, sbtScalaOrganization, sbtScalaVersion, sbtScalaJars, interProjectDependencies, excludeDependencies, fallbackDependencies)
|
||||
def apply(log: xsbti.Logger, resolvers: Vector[sbt.librarymanagement.Resolver], reorderResolvers: Boolean, parallelDownloads: Int, maxIterations: Int, sbtScalaOrganization: String, sbtScalaVersion: String, sbtScalaJars: Vector[java.io.File], interProjectDependencies: Vector[coursier.core.Project], excludeDependencies: Vector[(String, String)], fallbackDependencies: Vector[coursier.lmcoursier.FallbackDependency]): CoursierConfiguration = new CoursierConfiguration(Option(log), resolvers, reorderResolvers, parallelDownloads, maxIterations, Option(sbtScalaOrganization), Option(sbtScalaVersion), sbtScalaJars, interProjectDependencies, excludeDependencies, fallbackDependencies)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,12 @@
|
|||
"type": "(String, String)*",
|
||||
"default": "Vector.empty",
|
||||
"since": "0.0.1"
|
||||
},
|
||||
{
|
||||
"name": "fallbackDependencies",
|
||||
"type": "coursier.lmcoursier.FallbackDependency*",
|
||||
"default": "Vector.empty",
|
||||
"since": "0.0.1"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
|||
|
||||
val resolutionParams = ResolutionParams(
|
||||
dependencies = dependencies,
|
||||
fallbackDependencies = Nil,
|
||||
fallbackDependencies = conf.fallbackDependencies,
|
||||
configGraphs = configGraphs,
|
||||
autoScalaLib = true,
|
||||
mainRepositories = mainRepositories,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
package coursier.lmcoursier
|
||||
|
||||
import java.net.URL
|
||||
|
||||
import coursier.core.Module
|
||||
|
||||
// FIXME Handle that via the contraband thing?
|
||||
final case class FallbackDependency(
|
||||
module: Module,
|
||||
version: String,
|
||||
url: URL,
|
||||
changing: Boolean
|
||||
)
|
||||
|
|
@ -94,14 +94,14 @@ object FromSbt {
|
|||
allDependencies: Seq[ModuleID],
|
||||
scalaVersion: String,
|
||||
scalaBinaryVersion: String
|
||||
): Seq[(Module, String, URL, Boolean)] =
|
||||
): Seq[FallbackDependency] =
|
||||
for {
|
||||
module <- allDependencies
|
||||
artifact <- module.explicitArtifacts
|
||||
url <- artifact.url.toSeq
|
||||
} yield {
|
||||
val (module0, version) = moduleVersion(module, scalaVersion, scalaBinaryVersion)
|
||||
(module0, version, url, module.isChanging)
|
||||
FallbackDependency(module0, version, url, module.isChanging)
|
||||
}
|
||||
|
||||
def sbtClassifiersProject(
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import scala.concurrent.duration.Duration
|
|||
|
||||
final case class ResolutionParams(
|
||||
dependencies: Seq[(Configuration, Dependency)],
|
||||
fallbackDependencies: Seq[(Module, String, URL, Boolean)],
|
||||
fallbackDependencies: Seq[FallbackDependency],
|
||||
configGraphs: Seq[Set[Configuration]],
|
||||
autoScalaLib: Boolean,
|
||||
mainRepositories: Seq[Repository],
|
||||
|
|
@ -42,7 +42,7 @@ final case class ResolutionParams(
|
|||
Nil
|
||||
else {
|
||||
val map = fallbackDependencies.map {
|
||||
case (mod, ver, url, changing) =>
|
||||
case FallbackDependency(mod, ver, url, changing) =>
|
||||
(mod, ver) -> ((url, changing))
|
||||
}.toMap
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package coursier.sbtcoursiershared
|
||||
|
||||
import java.net.URL
|
||||
|
||||
import coursier.core._
|
||||
import coursier.lmcoursier._
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport._
|
||||
|
|
@ -44,4 +46,27 @@ object InputsTasks {
|
|||
Def.task(t.value)
|
||||
}
|
||||
|
||||
def coursierFallbackDependenciesTask: Def.Initialize[sbt.Task[Seq[FallbackDependency]]] =
|
||||
Def.taskDyn {
|
||||
|
||||
val state = sbt.Keys.state.value
|
||||
val projectRef = sbt.Keys.thisProjectRef.value
|
||||
|
||||
val projects = allRecursiveInterDependencies(state, projectRef)
|
||||
|
||||
val allDependenciesTask = allDependencies
|
||||
.forAllProjects(state, projectRef +: projects)
|
||||
.map(_.values.toVector.flatten)
|
||||
|
||||
Def.task {
|
||||
val allDependencies = allDependenciesTask.value
|
||||
|
||||
FromSbt.fallbackDependencies(
|
||||
allDependencies,
|
||||
scalaVersion.in(projectRef).get(state),
|
||||
scalaBinaryVersion.in(projectRef).get(state)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package coursier.sbtcoursiershared
|
||||
|
||||
import coursier.core.{Configuration, Project, Publication}
|
||||
import coursier.lmcoursier.SbtCoursierCache
|
||||
import java.net.URL
|
||||
|
||||
import coursier.core.{Configuration, Module, Project, Publication}
|
||||
import coursier.lmcoursier.{FallbackDependency, SbtCoursierCache}
|
||||
import sbt.{AutoPlugin, Classpaths, Compile, Setting, TaskKey, Test, settingKey, taskKey}
|
||||
import sbt.Keys._
|
||||
import sbt.librarymanagement.{Resolver, URLRepository}
|
||||
|
|
@ -25,6 +27,8 @@ object SbtCoursierShared extends AutoPlugin {
|
|||
val coursierResolvers = taskKey[Seq[Resolver]]("")
|
||||
val coursierRecursiveResolvers = taskKey[Seq[Resolver]]("Resolvers of the current project, plus those of all from its inter-dependency projects")
|
||||
val coursierSbtResolvers = taskKey[Seq[Resolver]]("")
|
||||
|
||||
val coursierFallbackDependencies = taskKey[Seq[FallbackDependency]]("")
|
||||
}
|
||||
|
||||
import autoImport._
|
||||
|
|
@ -94,7 +98,8 @@ object SbtCoursierShared extends AutoPlugin {
|
|||
resolvers0.filter { r =>
|
||||
!r.name.startsWith("local-preloaded")
|
||||
}
|
||||
}
|
||||
},
|
||||
coursierFallbackDependencies := InputsTasks.coursierFallbackDependenciesTask.value,
|
||||
) ++ {
|
||||
if (pubSettings)
|
||||
IvyXml.generateIvyXmlSettings()
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ object CoursierPlugin extends AutoPlugin {
|
|||
val mavenProfiles = Keys.mavenProfiles
|
||||
val coursierUseSbtCredentials = Keys.coursierUseSbtCredentials
|
||||
val coursierCredentials = Keys.coursierCredentials
|
||||
val coursierFallbackDependencies = Keys.coursierFallbackDependencies
|
||||
val coursierCache = Keys.coursierCache
|
||||
val coursierConfigGraphs = Keys.coursierConfigGraphs
|
||||
val coursierSbtClassifiersModule = Keys.coursierSbtClassifiersModule
|
||||
|
|
@ -140,7 +139,6 @@ object CoursierPlugin extends AutoPlugin {
|
|||
def coursierSettings(
|
||||
shadedConfigOpt: Option[(String, Configuration)] = None
|
||||
): Seq[Setting[_]] = hackHack ++ Seq(
|
||||
coursierFallbackDependencies := InputsTasks.coursierFallbackDependenciesTask.value,
|
||||
coursierArtifacts := ArtifactsTasks.artifactsTask(withClassifiers = false).value,
|
||||
coursierSignedArtifacts := ArtifactsTasks.artifactsTask(withClassifiers = false, includeSignatures = true).value,
|
||||
coursierClassifiersArtifacts := ArtifactsTasks.artifactsTask(
|
||||
|
|
|
|||
|
|
@ -14,29 +14,6 @@ import sbt.Keys._
|
|||
|
||||
object InputsTasks {
|
||||
|
||||
def coursierFallbackDependenciesTask: Def.Initialize[sbt.Task[Seq[(Module, String, URL, Boolean)]]] =
|
||||
Def.taskDyn {
|
||||
|
||||
val state = sbt.Keys.state.value
|
||||
val projectRef = sbt.Keys.thisProjectRef.value
|
||||
|
||||
val projects = allRecursiveInterDependencies(state, projectRef)
|
||||
|
||||
val allDependenciesTask = allDependencies
|
||||
.forAllProjects(state, projectRef +: projects)
|
||||
.map(_.values.toVector.flatten)
|
||||
|
||||
Def.task {
|
||||
val allDependencies = allDependenciesTask.value
|
||||
|
||||
FromSbt.fallbackDependencies(
|
||||
allDependencies,
|
||||
scalaVersion.in(projectRef).get(state),
|
||||
scalaBinaryVersion.in(projectRef).get(state)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
def coursierConfigurationsTask(
|
||||
shadedConfig: Option[(String, Configuration)]
|
||||
): Def.Initialize[sbt.Task[Map[Configuration, Set[Configuration]]]] =
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@ object Keys {
|
|||
|
||||
val coursierCache = SettingKey[File]("coursier-cache")
|
||||
|
||||
val coursierFallbackDependencies = TaskKey[Seq[(Module, String, URL, Boolean)]]("coursier-fallback-dependencies")
|
||||
|
||||
val coursierConfigGraphs = TaskKey[Seq[Set[Configuration]]]("coursier-config-graphs")
|
||||
|
||||
val coursierSbtClassifiersModule = TaskKey[GetClassifiersModule]("coursier-sbt-classifiers-module")
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ object ResolutionTasks {
|
|||
sbtClassifiers: Boolean = false
|
||||
): Def.Initialize[sbt.Task[Map[Set[Configuration], coursier.Resolution]]] = {
|
||||
|
||||
val currentProjectTask: sbt.Def.Initialize[sbt.Task[(Project, Seq[(Module, String, URL, Boolean)], Seq[Set[Configuration]])]] =
|
||||
val currentProjectTask: sbt.Def.Initialize[sbt.Task[(Project, Seq[FallbackDependency], Seq[Set[Configuration]])]] =
|
||||
if (sbtClassifiers)
|
||||
Def.task {
|
||||
val sv = scalaVersion.value
|
||||
|
|
|
|||
|
|
@ -54,11 +54,13 @@ object LmCoursierPlugin extends AutoPlugin {
|
|||
scalaBinaryVersion.value,
|
||||
streams.value.log
|
||||
)
|
||||
val fallbackDeps = coursierFallbackDependencies.value
|
||||
val s = streams.value
|
||||
Classpaths.warnResolversConflict(rs, s.log)
|
||||
CoursierConfiguration()
|
||||
.withResolvers(rs.toVector)
|
||||
.withInterProjectDependencies(interProjectDependencies.toVector)
|
||||
.withFallbackDependencies(fallbackDeps.toVector)
|
||||
.withExcludeDependencies(
|
||||
excludeDeps
|
||||
.toVector
|
||||
|
|
|
|||
Loading…
Reference in New Issue