mirror of https://github.com/sbt/sbt.git
Take dependencyOverrides into account in sbt-lm-coursier (#106)
This commit is contained in:
parent
0400b537f4
commit
e39b9cf55c
|
|
@ -8,7 +8,7 @@ package lmcoursier
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
import lmcoursier.credentials.Credentials
|
import lmcoursier.credentials.Credentials
|
||||||
import lmcoursier.definitions.{Authentication, CacheLogger, Project, Strict}
|
import lmcoursier.definitions.{Authentication, CacheLogger, Module, Project, Strict}
|
||||||
import sbt.librarymanagement.Resolver
|
import sbt.librarymanagement.Resolver
|
||||||
import xsbti.Logger
|
import xsbti.Logger
|
||||||
|
|
||||||
|
|
@ -36,7 +36,8 @@ final class CoursierConfiguration private (
|
||||||
val ivyHome: Option[File],
|
val ivyHome: Option[File],
|
||||||
val followHttpToHttpsRedirections: Option[Boolean],
|
val followHttpToHttpsRedirections: Option[Boolean],
|
||||||
val strict: Option[Strict],
|
val strict: Option[Strict],
|
||||||
val extraProjects: Vector[Project]
|
val extraProjects: Vector[Project],
|
||||||
|
val forceVersions: Vector[(Module, String)]
|
||||||
) extends Serializable {
|
) extends Serializable {
|
||||||
|
|
||||||
private def this() =
|
private def this() =
|
||||||
|
|
@ -64,6 +65,7 @@ final class CoursierConfiguration private (
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
Vector.empty,
|
||||||
Vector.empty
|
Vector.empty
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -115,6 +117,7 @@ final class CoursierConfiguration private (
|
||||||
ivyHome,
|
ivyHome,
|
||||||
followHttpToHttpsRedirections,
|
followHttpToHttpsRedirections,
|
||||||
None,
|
None,
|
||||||
|
Vector.empty,
|
||||||
Vector.empty
|
Vector.empty
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -144,7 +147,8 @@ final class CoursierConfiguration private (
|
||||||
ivyHome == other.ivyHome &&
|
ivyHome == other.ivyHome &&
|
||||||
followHttpToHttpsRedirections == other.followHttpToHttpsRedirections &&
|
followHttpToHttpsRedirections == other.followHttpToHttpsRedirections &&
|
||||||
strict == other.strict &&
|
strict == other.strict &&
|
||||||
extraProjects == other.extraProjects
|
extraProjects == other.extraProjects &&
|
||||||
|
forceVersions == other.forceVersions
|
||||||
case _ => false
|
case _ => false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -174,11 +178,12 @@ final class CoursierConfiguration private (
|
||||||
code = 37 * (code + followHttpToHttpsRedirections.##)
|
code = 37 * (code + followHttpToHttpsRedirections.##)
|
||||||
code = 37 * (code + strict.##)
|
code = 37 * (code + strict.##)
|
||||||
code = 37 * (code + extraProjects.##)
|
code = 37 * (code + extraProjects.##)
|
||||||
|
code = 37 * (code + forceVersions.##)
|
||||||
code
|
code
|
||||||
}
|
}
|
||||||
|
|
||||||
override def toString: String =
|
override def toString: String =
|
||||||
s"CoursierConfiguration($log, $resolvers, $parallelDownloads, $maxIterations, $sbtScalaOrganization, $sbtScalaVersion, $sbtScalaJars, $interProjectDependencies, $excludeDependencies, $fallbackDependencies, $autoScalaLibrary, $hasClassifiers, $classifiers, $mavenProfiles, $scalaOrganization, $scalaVersion, $authenticationByRepositoryId, $credentials, $logger, $cache, $ivyHome, $followHttpToHttpsRedirections, $strict, $extraProjects)"
|
s"CoursierConfiguration($log, $resolvers, $parallelDownloads, $maxIterations, $sbtScalaOrganization, $sbtScalaVersion, $sbtScalaJars, $interProjectDependencies, $excludeDependencies, $fallbackDependencies, $autoScalaLibrary, $hasClassifiers, $classifiers, $mavenProfiles, $scalaOrganization, $scalaVersion, $authenticationByRepositoryId, $credentials, $logger, $cache, $ivyHome, $followHttpToHttpsRedirections, $strict, $extraProjects, $forceVersions)"
|
||||||
|
|
||||||
private[this] def copy(
|
private[this] def copy(
|
||||||
log: Option[Logger] = log,
|
log: Option[Logger] = log,
|
||||||
|
|
@ -204,7 +209,8 @@ final class CoursierConfiguration private (
|
||||||
ivyHome: Option[File] = ivyHome,
|
ivyHome: Option[File] = ivyHome,
|
||||||
followHttpToHttpsRedirections: Option[Boolean] = followHttpToHttpsRedirections,
|
followHttpToHttpsRedirections: Option[Boolean] = followHttpToHttpsRedirections,
|
||||||
strict: Option[Strict] = strict,
|
strict: Option[Strict] = strict,
|
||||||
extraProjects: Vector[Project] = extraProjects
|
extraProjects: Vector[Project] = extraProjects,
|
||||||
|
forceVersions: Vector[(Module, String)] = forceVersions
|
||||||
): CoursierConfiguration =
|
): CoursierConfiguration =
|
||||||
new CoursierConfiguration(
|
new CoursierConfiguration(
|
||||||
log,
|
log,
|
||||||
|
|
@ -230,7 +236,8 @@ final class CoursierConfiguration private (
|
||||||
ivyHome,
|
ivyHome,
|
||||||
followHttpToHttpsRedirections,
|
followHttpToHttpsRedirections,
|
||||||
strict,
|
strict,
|
||||||
extraProjects
|
extraProjects,
|
||||||
|
forceVersions
|
||||||
)
|
)
|
||||||
|
|
||||||
def withLog(log: Option[Logger]): CoursierConfiguration =
|
def withLog(log: Option[Logger]): CoursierConfiguration =
|
||||||
|
|
@ -333,6 +340,9 @@ final class CoursierConfiguration private (
|
||||||
|
|
||||||
def withExtraProjects(extraProjects: Vector[Project]): CoursierConfiguration =
|
def withExtraProjects(extraProjects: Vector[Project]): CoursierConfiguration =
|
||||||
copy(extraProjects = extraProjects)
|
copy(extraProjects = extraProjects)
|
||||||
|
|
||||||
|
def withForceVersions(forceVersions: Vector[(Module, String)]): CoursierConfiguration =
|
||||||
|
copy(forceVersions = forceVersions)
|
||||||
}
|
}
|
||||||
|
|
||||||
object CoursierConfiguration {
|
object CoursierConfiguration {
|
||||||
|
|
@ -386,6 +396,7 @@ object CoursierConfiguration {
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
Vector.empty,
|
||||||
Vector.empty
|
Vector.empty
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -435,6 +446,7 @@ object CoursierConfiguration {
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
Vector.empty,
|
||||||
Vector.empty
|
Vector.empty
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -485,6 +497,7 @@ object CoursierConfiguration {
|
||||||
ivyHome,
|
ivyHome,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
Vector.empty,
|
||||||
Vector.empty
|
Vector.empty
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
||||||
params = coursier.params.ResolutionParams()
|
params = coursier.params.ResolutionParams()
|
||||||
.withMaxIterations(conf.maxIterations)
|
.withMaxIterations(conf.maxIterations)
|
||||||
.withProfiles(conf.mavenProfiles.toSet)
|
.withProfiles(conf.mavenProfiles.toSet)
|
||||||
.withForceVersion(Map.empty)
|
.withForceVersion(conf.forceVersions.map { case (k, v) => (ToCoursier.module(k), v) }.toMap)
|
||||||
.withTypelevel(typelevel),
|
.withTypelevel(typelevel),
|
||||||
strictOpt = conf.strict.map(ToCoursier.strict)
|
strictOpt = conf.strict.map(ToCoursier.strict)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
package lmcoursier
|
package lmcoursier
|
||||||
|
|
||||||
import coursier.ivy.IvyXml.{mappings => initialIvyXmlMappings}
|
import coursier.ivy.IvyXml.{mappings => initialIvyXmlMappings}
|
||||||
import lmcoursier.definitions.{Configuration, ModuleName, Organization}
|
import lmcoursier.definitions.{Configuration, Module, ModuleName, Organization, ToCoursier}
|
||||||
import sbt.librarymanagement.{CrossVersion, InclExclRule}
|
import sbt.librarymanagement.{CrossVersion, InclExclRule, ModuleID}
|
||||||
import sbt.util.Logger
|
import sbt.util.Logger
|
||||||
|
|
||||||
import scala.collection.mutable
|
import scala.collection.mutable
|
||||||
|
|
@ -124,4 +124,7 @@ object Inputs {
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def forceVersions(depOverrides: Seq[ModuleID], sv: String, sbv: String): Seq[(Module, String)] =
|
||||||
|
depOverrides.map(FromSbt.moduleVersion(_, sv, sbv))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,14 @@ import coursier.ProjectCache
|
||||||
import coursier.cache.FileCache
|
import coursier.cache.FileCache
|
||||||
import coursier.core._
|
import coursier.core._
|
||||||
import coursier.internal.Typelevel
|
import coursier.internal.Typelevel
|
||||||
import lmcoursier.definitions.{Strict, ToCoursier}
|
import lmcoursier.definitions.ToCoursier
|
||||||
import lmcoursier.{FallbackDependency, FromSbt}
|
import lmcoursier.{FallbackDependency, FromSbt, Inputs}
|
||||||
import lmcoursier.internal.{InterProjectRepository, ResolutionParams, ResolutionRun, Resolvers}
|
import lmcoursier.internal.{InterProjectRepository, ResolutionParams, ResolutionRun, Resolvers}
|
||||||
import coursier.sbtcoursier.Keys._
|
import coursier.sbtcoursier.Keys._
|
||||||
import coursier.sbtcoursiershared.InputsTasks.{credentialsTask, strictTask}
|
import coursier.sbtcoursiershared.InputsTasks.{credentialsTask, strictTask}
|
||||||
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport._
|
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport._
|
||||||
import sbt.Def
|
import sbt.Def
|
||||||
import sbt.Keys._
|
import sbt.Keys._
|
||||||
import sbt.librarymanagement.ConflictManager
|
|
||||||
|
|
||||||
object ResolutionTasks {
|
object ResolutionTasks {
|
||||||
|
|
||||||
|
|
@ -71,14 +70,7 @@ object ResolutionTasks {
|
||||||
// are these always defined? (e.g. for Java only projects?)
|
// are these always defined? (e.g. for Java only projects?)
|
||||||
val so = Organization(scalaOrganization.value)
|
val so = Organization(scalaOrganization.value)
|
||||||
|
|
||||||
val userForceVersions = dependencyOverrides
|
val userForceVersions = Inputs.forceVersions(dependencyOverrides.value, sv, sbv)
|
||||||
.value
|
|
||||||
.map(FromSbt.moduleVersion(_, sv, sbv))
|
|
||||||
.map {
|
|
||||||
case (k, v) =>
|
|
||||||
ToCoursier.module(k) -> v
|
|
||||||
}
|
|
||||||
.toMap
|
|
||||||
|
|
||||||
val verbosityLevel = coursierVerbosity.value
|
val verbosityLevel = coursierVerbosity.value
|
||||||
|
|
||||||
|
|
@ -148,7 +140,7 @@ object ResolutionTasks {
|
||||||
params = coursier.params.ResolutionParams()
|
params = coursier.params.ResolutionParams()
|
||||||
.withMaxIterations(maxIterations)
|
.withMaxIterations(maxIterations)
|
||||||
.withProfiles(userEnabledProfiles)
|
.withProfiles(userEnabledProfiles)
|
||||||
.withForceVersion(userForceVersions)
|
.withForceVersion(userForceVersions.map { case (k, v) => (ToCoursier.module(k), v) }.toMap)
|
||||||
.withTypelevel(typelevel),
|
.withTypelevel(typelevel),
|
||||||
strictOpt = strictOpt
|
strictOpt = strictOpt
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
scalaVersion := "2.12.8"
|
||||||
|
libraryDependencies += "io.get-coursier" %% "coursier" % "2.0.0-RC2-6"
|
||||||
|
dependencyOverrides += "io.get-coursier" %% "coursier-core" % "1.1.0-M14-7"
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
addSbtPlugin {
|
||||||
|
|
||||||
|
val name = sys.props.getOrElse(
|
||||||
|
"plugin.name",
|
||||||
|
sys.error("plugin.name Java property not set")
|
||||||
|
)
|
||||||
|
val version = sys.props.getOrElse(
|
||||||
|
"plugin.version",
|
||||||
|
sys.error("plugin.version Java property not set")
|
||||||
|
)
|
||||||
|
|
||||||
|
"io.get-coursier" % name % version
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
import coursier.util.Properties
|
||||||
|
|
||||||
|
object Main extends App {
|
||||||
|
val expected = "1.1.0-M14-7"
|
||||||
|
assert(
|
||||||
|
Properties.version == expected,
|
||||||
|
s"Expected coursier-core $expected, got ${Properties.version}"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
> run
|
||||||
|
|
@ -7,7 +7,7 @@ import coursier.sbtcoursiershared.{InputsTasks, SbtCoursierShared}
|
||||||
import sbt.{AutoPlugin, Classpaths, Def, Setting, Task, taskKey}
|
import sbt.{AutoPlugin, Classpaths, Def, Setting, Task, taskKey}
|
||||||
import sbt.Project.inTask
|
import sbt.Project.inTask
|
||||||
import sbt.KeyRanks.DTask
|
import sbt.KeyRanks.DTask
|
||||||
import sbt.Keys.{appConfiguration, autoScalaLibrary, classpathTypes, dependencyResolution, ivyPaths, scalaBinaryVersion, scalaModuleInfo, scalaOrganization, scalaVersion, streams, updateClassifiers, updateSbtClassifiers}
|
import sbt.Keys.{appConfiguration, autoScalaLibrary, classpathTypes, dependencyOverrides, dependencyResolution, ivyPaths, scalaBinaryVersion, scalaModuleInfo, scalaOrganization, scalaVersion, streams, updateClassifiers, updateSbtClassifiers}
|
||||||
import sbt.librarymanagement.DependencyResolution
|
import sbt.librarymanagement.DependencyResolution
|
||||||
|
|
||||||
import scala.language.reflectiveCalls
|
import scala.language.reflectiveCalls
|
||||||
|
|
@ -83,6 +83,7 @@ object LmCoursierPlugin extends AutoPlugin {
|
||||||
val rs = resolversTask.value
|
val rs = resolversTask.value
|
||||||
val scalaOrg = scalaOrganization.value
|
val scalaOrg = scalaOrganization.value
|
||||||
val scalaVer = scalaVersion.value
|
val scalaVer = scalaVersion.value
|
||||||
|
val sbv = scalaBinaryVersion.value
|
||||||
val interProjectDependencies = interProjectDependenciesTask.value
|
val interProjectDependencies = interProjectDependenciesTask.value
|
||||||
val extraProjects = coursierExtraProjects.value
|
val extraProjects = coursierExtraProjects.value
|
||||||
val excludeDeps = Inputs.exclusions(
|
val excludeDeps = Inputs.exclusions(
|
||||||
|
|
@ -95,6 +96,9 @@ object LmCoursierPlugin extends AutoPlugin {
|
||||||
val autoScalaLib = autoScalaLibrary.value && scalaModuleInfo.value.forall(_.overrideScalaVersion)
|
val autoScalaLib = autoScalaLibrary.value && scalaModuleInfo.value.forall(_.overrideScalaVersion)
|
||||||
val profiles = mavenProfiles.value
|
val profiles = mavenProfiles.value
|
||||||
|
|
||||||
|
|
||||||
|
val userForceVersions = Inputs.forceVersions(dependencyOverrides.value, scalaVer, sbv)
|
||||||
|
|
||||||
val authenticationByRepositoryId = coursierCredentials.value.mapValues { c =>
|
val authenticationByRepositoryId = coursierCredentials.value.mapValues { c =>
|
||||||
val a = c.authentication
|
val a = c.authentication
|
||||||
Authentication(a.user, a.password, a.optional, a.realmOpt)
|
Authentication(a.user, a.password, a.optional, a.realmOpt)
|
||||||
|
|
@ -143,6 +147,7 @@ object LmCoursierPlugin extends AutoPlugin {
|
||||||
.withLog(s.log)
|
.withLog(s.log)
|
||||||
.withIvyHome(ivyPaths.value.ivyHome)
|
.withIvyHome(ivyPaths.value.ivyHome)
|
||||||
.withStrict(strict)
|
.withStrict(strict)
|
||||||
|
.withForceVersions(userForceVersions.toVector)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private def mkDependencyResolution: Def.Initialize[Task[DependencyResolution]] =
|
private def mkDependencyResolution: Def.Initialize[Task[DependencyResolution]] =
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue