use Relaxed reconciliation strategy by default

Fixes #4720
Ref https://github.com/coursier/coursier/pull/1293
Ref https://github.com/coursier/sbt-coursier/pull/112
This commit is contained in:
Eugene Yokota 2019-08-04 01:16:42 -04:00
parent a22e4889f4
commit 46e92949ed
5 changed files with 26 additions and 11 deletions

View File

@ -249,6 +249,7 @@ object Defaults extends BuildCommon {
csrLogger := LMCoursier.coursierLoggerTask.value,
csrCacheDirectory :== LMCoursier.defaultCacheLocation,
csrMavenProfiles :== Set.empty,
csrReconciliations :== LMCoursier.relaxedForAllModules,
)
/** Core non-plugin settings for sbt builds. These *must* be on every build or the sbt engine will fail to run at all. */

View File

@ -10,7 +10,7 @@ package sbt
import java.io.File
import java.net.URL
import lmcoursier.definitions.CacheLogger
import lmcoursier.definitions.{ CacheLogger, ModuleMatchers, Reconciliation }
import lmcoursier.{ CoursierConfiguration, FallbackDependency }
import org.apache.ivy.core.module.descriptor.ModuleDescriptor
import org.apache.ivy.core.module.id.ModuleRevisionId
@ -339,6 +339,7 @@ object Keys {
val csrLogger = taskKey[Option[CacheLogger]]("")
val csrExtraCredentials = taskKey[Seq[lmcoursier.credentials.Credentials]]("")
val csrPublications = taskKey[Seq[(lmcoursier.definitions.Configuration, lmcoursier.definitions.Publication)]]("")
val csrReconciliations = settingKey[Seq[(ModuleMatchers, Reconciliation)]]("Strategy to reconcile version conflicts.")
val internalConfigurationMap = settingKey[Configuration => Configuration]("Maps configurations to the actual configuration used to define the classpath.").withRank(CSetting)
val classpathConfiguration = taskKey[Configuration]("The configuration used to define the classpath.").withRank(CTask)

View File

@ -13,15 +13,16 @@ import sbt.librarymanagement._
import sbt.util.Logger
import sbt.Keys._
import lmcoursier.definitions.{
Attributes => CAttributes,
Classifier => CClassifier,
Configuration => CConfiguration,
Dependency => CDependency,
Extension => CExtension,
Info => CInfo,
Module => CModule,
ModuleName => CModuleName,
Organization => COrganization,
Project => CProject,
Publication => CPublication,
Type => CType
}
import lmcoursier.credentials.DirectCredentials
@ -108,33 +109,34 @@ object CoursierInputsTasks {
val configurations = desc.getModuleConfigurations.toVector
.flatMap(Inputs.ivyXmlMappings)
def dependency(conf: CConfiguration, attr: CAttributes) = CDependency(
def dependency(conf: CConfiguration, pub: CPublication) = CDependency(
module,
id.getRevision,
conf,
exclusions,
attr,
pub,
optional = false,
desc.isTransitive
)
val attributes: CConfiguration => CAttributes = {
val publications: CConfiguration => CPublication = {
val artifacts = desc.getAllDependencyArtifacts
val m = artifacts.toVector.flatMap { art =>
val attr = CAttributes(CType(art.getType), CClassifier(""))
val pub =
CPublication(art.getName, CType(art.getType), CExtension(art.getExt()), CClassifier(""))
art.getConfigurations.map(CConfiguration(_)).toVector.map { conf =>
conf -> attr
conf -> pub
}
}.toMap
c => m.getOrElse(c, CAttributes(CType(""), CClassifier("")))
c => m.getOrElse(c, CPublication("", CType(""), CExtension(""), CClassifier("")))
}
configurations.map {
case (from, to) =>
from -> dependency(to, attributes(to))
from -> dependency(to, publications(to))
}
}

View File

@ -14,7 +14,9 @@ import lmcoursier.definitions.{
Classifier,
Configuration => CConfiguration,
CacheLogger,
Project => CProject
Project => CProject,
ModuleMatchers,
Reconciliation,
}
import lmcoursier._
import lmcoursier.credentials.Credentials
@ -40,6 +42,9 @@ object LMCoursier {
case _ => CoursierDependencyResolution.defaultCacheLocation
}
def relaxedForAllModules: Seq[(ModuleMatchers, Reconciliation)] =
Vector((ModuleMatchers.all, Reconciliation.Relaxed))
def coursierConfiguration(
rs: Seq[Resolver],
interProjectDependencies: Seq[CProject],
@ -56,6 +61,7 @@ object LMCoursier {
credentials: Seq[Credentials],
createLogger: Option[CacheLogger],
cacheDirectory: File,
reconciliation: Seq[(ModuleMatchers, Reconciliation)],
log: Logger
): CoursierConfiguration = {
val coursierExcludeDeps = Inputs
@ -96,6 +102,7 @@ object LMCoursier {
.withCredentials(credentials)
.withLogger(createLogger)
.withCache(cacheDirectory)
.withReconciliation(reconciliation.toVector)
.withLog(log)
}
@ -116,6 +123,7 @@ object LMCoursier {
CoursierInputsTasks.credentialsTask.value,
csrLogger.value,
csrCacheDirectory.value,
csrReconciliations.value,
streams.value.log
)
}
@ -137,6 +145,7 @@ object LMCoursier {
CoursierInputsTasks.credentialsTask.value,
csrLogger.value,
csrCacheDirectory.value,
csrReconciliations.value,
streams.value.log
)
}
@ -158,6 +167,7 @@ object LMCoursier {
CoursierInputsTasks.credentialsTask.value,
csrLogger.value,
csrCacheDirectory.value,
csrReconciliations.value,
streams.value.log
)
}
@ -179,6 +189,7 @@ object LMCoursier {
CoursierInputsTasks.credentialsTask.value,
csrLogger.value,
csrCacheDirectory.value,
csrReconciliations.value,
streams.value.log
)
}

View File

@ -112,7 +112,7 @@ object Dependencies {
def addSbtZincCompileCore(p: Project): Project =
addSbtModule(p, sbtZincPath, "zincCompileCore", zincCompileCore)
val lmCoursierVersion = "2.0.0-RC3"
val lmCoursierVersion = "2.0.0-RC3-2"
val lmCoursierShaded = "io.get-coursier" %% "lm-coursier-shaded" % lmCoursierVersion
val sjsonNewScalaJson = Def.setting {