mirror of
https://github.com/sbt/sbt.git
synced 2026-09-07 11:01:08 +02:00
Add support for dependencyOverrides in SBT plugin
This commit is contained in:
@@ -34,7 +34,21 @@ object FromSbt {
|
||||
!k.startsWith(SbtPomExtraProperties.POM_INFO_KEY_PREFIX)
|
||||
}
|
||||
|
||||
def dependencies(
|
||||
def moduleVersion(
|
||||
module: ModuleID,
|
||||
scalaVersion: String,
|
||||
scalaBinaryVersion: String
|
||||
): (Module, String) = {
|
||||
|
||||
val fullName = sbtModuleIdName(module, scalaVersion, scalaBinaryVersion)
|
||||
|
||||
val module0 = Module(module.organization, fullName, FromSbt.attributes(module.extraDependencyAttributes))
|
||||
val version = module.revision
|
||||
|
||||
(module0, version)
|
||||
}
|
||||
|
||||
def dependencies(
|
||||
module: ModuleID,
|
||||
scalaVersion: String,
|
||||
scalaBinaryVersion: String
|
||||
@@ -42,11 +56,11 @@ object FromSbt {
|
||||
|
||||
// TODO Warn about unsupported properties in `module`
|
||||
|
||||
val fullName = sbtModuleIdName(module, scalaVersion, scalaBinaryVersion)
|
||||
val (module0, version) = moduleVersion(module, scalaVersion, scalaBinaryVersion)
|
||||
|
||||
val dep = Dependency(
|
||||
Module(module.organization, fullName, FromSbt.attributes(module.extraDependencyAttributes)),
|
||||
module.revision,
|
||||
module0,
|
||||
version,
|
||||
exclusions = module.exclusions.map { rule =>
|
||||
// FIXME Other `rule` fields are ignored here
|
||||
(rule.organization, rule.name)
|
||||
|
||||
@@ -220,6 +220,11 @@ object Tasks {
|
||||
val cache = coursierCache.value
|
||||
|
||||
val sv = scalaVersion.value // is this always defined? (e.g. for Java only projects?)
|
||||
val sbv = scalaBinaryVersion.value
|
||||
|
||||
val userForceVersions = dependencyOverrides.value.map(
|
||||
FromSbt.moduleVersion(_, sv, sbv)
|
||||
).toMap
|
||||
|
||||
val resolvers =
|
||||
if (sbtClassifiers)
|
||||
@@ -233,7 +238,7 @@ object Tasks {
|
||||
val startRes = Resolution(
|
||||
currentProject.dependencies.map { case (_, dep) => dep }.toSet,
|
||||
filter = Some(dep => !dep.optional),
|
||||
forceVersions = forcedScalaModules(sv) ++ projects.map(_.moduleVersion)
|
||||
forceVersions = userForceVersions ++ forcedScalaModules(sv) ++ projects.map(_.moduleVersion)
|
||||
)
|
||||
|
||||
// required for publish to be fine, later on
|
||||
|
||||
Reference in New Issue
Block a user