mirror of https://github.com/sbt/sbt.git
Include reconciliation to CoursierConfiguration (#112)
Also re-enable sbt-contraband, and deal with Dependency change.
This commit is contained in:
parent
63ddd4c616
commit
ebe96c613f
|
|
@ -18,7 +18,7 @@ inThisBuild(List(
|
|||
val coursierVersion0 = "2.0.0-RC3-2"
|
||||
|
||||
lazy val `lm-coursier` = project
|
||||
// .enablePlugins(ContrabandPlugin)
|
||||
.enablePlugins(ContrabandPlugin)
|
||||
.in(file("modules/lm-coursier"))
|
||||
.settings(
|
||||
shared,
|
||||
|
|
@ -33,7 +33,8 @@ lazy val `lm-coursier` = project
|
|||
// is ignored).
|
||||
"org.scala-sbt" %% "librarymanagement-ivy" % "1.2.4",
|
||||
"org.scalatest" %% "scalatest" % "3.0.8" % Test
|
||||
)
|
||||
),
|
||||
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "scala",
|
||||
)
|
||||
|
||||
lazy val `lm-coursier-shaded` = project
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
package lmcoursier.definitions
|
||||
@target(Scala)
|
||||
|
||||
enum Reconciliation {
|
||||
Default
|
||||
Relaxed
|
||||
}
|
||||
|
|
@ -24,8 +24,8 @@
|
|||
"type": "Set[(Organization, ModuleName)]"
|
||||
},
|
||||
{
|
||||
"name": "attributes",
|
||||
"type": "Attributes"
|
||||
"name": "publication",
|
||||
"type": "Publication"
|
||||
},
|
||||
{
|
||||
"name": "optional",
|
||||
|
|
@ -35,6 +35,13 @@
|
|||
"name": "transitive",
|
||||
"type": "Boolean"
|
||||
}
|
||||
],
|
||||
"extra": [
|
||||
"def attributes: Attributes = publication.attributes",
|
||||
"def withAttributes(attributes: Attributes): Dependency = withPublication(publication.withType(attributes.`type`).withClassifier(attributes.classifier))"
|
||||
],
|
||||
"extraCompanion": [
|
||||
"def apply(module: Module, version: String, configuration: Configuration, exclusions: Set[(Organization, ModuleName)], attributes: Attributes, optional: Boolean, transitive: Boolean): Dependency = new Dependency(module, version, configuration, exclusions, Publication(\"\", attributes.`type`, Extension(\"\"), attributes.classifier), optional, transitive)"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -20,6 +20,30 @@
|
|||
"type": "Map[String, String]"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"name": "ModuleMatchers",
|
||||
"namespace": "lmcoursier.definitions",
|
||||
"target": "Scala",
|
||||
"parents": [],
|
||||
"type": "record",
|
||||
"fields": [
|
||||
{
|
||||
"name": "exclude",
|
||||
"type": "Set[lmcoursier.definitions.Module]",
|
||||
"doc": "Use \"*\" in either organization or name to match any."
|
||||
},
|
||||
{
|
||||
"name": "include",
|
||||
"type": "Set[lmcoursier.definitions.Module]",
|
||||
"doc": "Use \"*\" in either organization or name to match any."
|
||||
}
|
||||
],
|
||||
"extraCompanion": [
|
||||
"/** ModuleMatchers that matches to any modules. */",
|
||||
"def all: ModuleMatchers = ModuleMatchers(Set.empty, Set.empty)"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@
|
|||
"name": "classifier",
|
||||
"type": "Classifier"
|
||||
}
|
||||
],
|
||||
"extra": [
|
||||
"def attributes: Attributes = Attributes(`type`, classifier)",
|
||||
"def withAttributes(attributes: Attributes): Publication = withType(attributes.`type`).withClassifier(attributes.classifier)"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ package lmcoursier
|
|||
import java.io.File
|
||||
|
||||
import lmcoursier.credentials.Credentials
|
||||
import lmcoursier.definitions.{Authentication, CacheLogger, Module, Project, Strict}
|
||||
import lmcoursier.definitions.{Authentication, CacheLogger, Module, ModuleMatchers, Project, Reconciliation, Strict}
|
||||
import sbt.librarymanagement.Resolver
|
||||
import xsbti.Logger
|
||||
|
||||
|
|
@ -37,7 +37,8 @@ final class CoursierConfiguration private (
|
|||
val followHttpToHttpsRedirections: Option[Boolean],
|
||||
val strict: Option[Strict],
|
||||
val extraProjects: Vector[Project],
|
||||
val forceVersions: Vector[(Module, String)]
|
||||
val forceVersions: Vector[(Module, String)],
|
||||
val reconciliation: Vector[(ModuleMatchers, Reconciliation)]
|
||||
) extends Serializable {
|
||||
|
||||
private def this() =
|
||||
|
|
@ -66,6 +67,7 @@ final class CoursierConfiguration private (
|
|||
None,
|
||||
None,
|
||||
Vector.empty,
|
||||
Vector.empty,
|
||||
Vector.empty
|
||||
)
|
||||
|
||||
|
|
@ -118,9 +120,66 @@ final class CoursierConfiguration private (
|
|||
followHttpToHttpsRedirections,
|
||||
None,
|
||||
Vector.empty,
|
||||
Vector.empty,
|
||||
Vector.empty
|
||||
)
|
||||
|
||||
|
||||
def this(
|
||||
log: Option[Logger],
|
||||
resolvers: Vector[Resolver],
|
||||
parallelDownloads: Int,
|
||||
maxIterations: Int,
|
||||
sbtScalaOrganization: Option[String],
|
||||
sbtScalaVersion: Option[String],
|
||||
sbtScalaJars: Vector[File],
|
||||
interProjectDependencies: Vector[Project],
|
||||
excludeDependencies: Vector[(String, String)],
|
||||
fallbackDependencies: Vector[FallbackDependency],
|
||||
autoScalaLibrary: Boolean,
|
||||
hasClassifiers: Boolean,
|
||||
classifiers: Vector[String],
|
||||
mavenProfiles: Vector[String],
|
||||
scalaOrganization: Option[String],
|
||||
scalaVersion: Option[String],
|
||||
authenticationByRepositoryId: Vector[(String, Authentication)],
|
||||
credentials: Seq[Credentials],
|
||||
logger: Option[CacheLogger],
|
||||
cache: Option[File],
|
||||
ivyHome: Option[File],
|
||||
followHttpToHttpsRedirections: Option[Boolean],
|
||||
strict: Option[Strict],
|
||||
extraProjects: Vector[Project],
|
||||
forceVersions: Vector[(Module, String)],
|
||||
) =
|
||||
this(
|
||||
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,
|
||||
Vector.empty
|
||||
)
|
||||
|
||||
override def equals(o: Any): Boolean =
|
||||
o match {
|
||||
case other: CoursierConfiguration =>
|
||||
|
|
@ -148,7 +207,8 @@ final class CoursierConfiguration private (
|
|||
followHttpToHttpsRedirections == other.followHttpToHttpsRedirections &&
|
||||
strict == other.strict &&
|
||||
extraProjects == other.extraProjects &&
|
||||
forceVersions == other.forceVersions
|
||||
forceVersions == other.forceVersions &&
|
||||
reconciliation == other.reconciliation
|
||||
case _ => false
|
||||
}
|
||||
|
||||
|
|
@ -179,6 +239,7 @@ final class CoursierConfiguration private (
|
|||
code = 37 * (code + strict.##)
|
||||
code = 37 * (code + extraProjects.##)
|
||||
code = 37 * (code + forceVersions.##)
|
||||
code = 37 * (code + reconciliation.##)
|
||||
code
|
||||
}
|
||||
|
||||
|
|
@ -210,7 +271,8 @@ final class CoursierConfiguration private (
|
|||
followHttpToHttpsRedirections: Option[Boolean] = followHttpToHttpsRedirections,
|
||||
strict: Option[Strict] = strict,
|
||||
extraProjects: Vector[Project] = extraProjects,
|
||||
forceVersions: Vector[(Module, String)] = forceVersions
|
||||
forceVersions: Vector[(Module, String)] = forceVersions,
|
||||
reconciliation: Vector[(ModuleMatchers, Reconciliation)] = reconciliation
|
||||
): CoursierConfiguration =
|
||||
new CoursierConfiguration(
|
||||
log,
|
||||
|
|
@ -237,7 +299,8 @@ final class CoursierConfiguration private (
|
|||
followHttpToHttpsRedirections,
|
||||
strict,
|
||||
extraProjects,
|
||||
forceVersions
|
||||
forceVersions,
|
||||
reconciliation
|
||||
)
|
||||
|
||||
def withLog(log: Option[Logger]): CoursierConfiguration =
|
||||
|
|
@ -343,6 +406,9 @@ final class CoursierConfiguration private (
|
|||
|
||||
def withForceVersions(forceVersions: Vector[(Module, String)]): CoursierConfiguration =
|
||||
copy(forceVersions = forceVersions)
|
||||
|
||||
def withReconciliation(reconciliation: Vector[(ModuleMatchers, Reconciliation)]): CoursierConfiguration =
|
||||
copy(reconciliation = reconciliation)
|
||||
}
|
||||
|
||||
object CoursierConfiguration {
|
||||
|
|
@ -397,6 +463,7 @@ object CoursierConfiguration {
|
|||
None,
|
||||
None,
|
||||
Vector.empty,
|
||||
Vector.empty,
|
||||
Vector.empty
|
||||
)
|
||||
|
||||
|
|
@ -447,6 +514,7 @@ object CoursierConfiguration {
|
|||
None,
|
||||
None,
|
||||
Vector.empty,
|
||||
Vector.empty,
|
||||
Vector.empty
|
||||
)
|
||||
|
||||
|
|
@ -498,6 +566,7 @@ object CoursierConfiguration {
|
|||
None,
|
||||
None,
|
||||
Vector.empty,
|
||||
Vector.empty,
|
||||
Vector.empty
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,7 +158,8 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
|||
.withMaxIterations(conf.maxIterations)
|
||||
.withProfiles(conf.mavenProfiles.toSet)
|
||||
.withForceVersion(conf.forceVersions.map { case (k, v) => (ToCoursier.module(k), v) }.toMap)
|
||||
.withTypelevel(typelevel),
|
||||
.withTypelevel(typelevel)
|
||||
.withReconciliation(ToCoursier.reconciliation(conf.reconciliation)),
|
||||
strictOpt = conf.strict.map(ToCoursier.strict)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -12,11 +12,10 @@ final class Dependency private (
|
|||
val publication: Publication,
|
||||
val optional: Boolean,
|
||||
val transitive: Boolean) extends Serializable {
|
||||
|
||||
|
||||
def attributes: Attributes =
|
||||
publication.attributes
|
||||
|
||||
def attributes: Attributes = publication.attributes
|
||||
def withAttributes(attributes: Attributes): Dependency = withPublication(publication.withType(attributes.`type`).withClassifier(attributes.classifier))
|
||||
|
||||
|
||||
override def equals(o: Any): Boolean = o match {
|
||||
case x: Dependency => (this.module == x.module) && (this.version == x.version) && (this.configuration == x.configuration) && (this.exclusions == x.exclusions) && (this.publication == x.publication) && (this.optional == x.optional) && (this.transitive == x.transitive)
|
||||
case _ => false
|
||||
|
|
@ -42,12 +41,6 @@ final class Dependency private (
|
|||
def withExclusions(exclusions: Set[(Organization, ModuleName)]): Dependency = {
|
||||
copy(exclusions = exclusions)
|
||||
}
|
||||
def withAttributes(attributes: Attributes): Dependency =
|
||||
copy(
|
||||
publication = publication
|
||||
.withType(attributes.`type`)
|
||||
.withClassifier(attributes.classifier)
|
||||
)
|
||||
def withPublication(publication: Publication): Dependency = {
|
||||
copy(publication = publication)
|
||||
}
|
||||
|
|
@ -59,7 +52,6 @@ final class Dependency private (
|
|||
}
|
||||
}
|
||||
object Dependency {
|
||||
|
||||
def apply(module: Module, version: String, configuration: Configuration, exclusions: Set[(Organization, ModuleName)], attributes: Attributes, optional: Boolean, transitive: Boolean): Dependency = new Dependency(module, version, configuration, exclusions, Publication("", attributes.`type`, Extension(""), attributes.classifier), optional, transitive)
|
||||
def apply(module: Module, version: String, configuration: Configuration, exclusions: Set[(Organization, ModuleName)], publication: Publication, optional: Boolean, transitive: Boolean): Dependency = new Dependency(module, version, configuration, exclusions, publication, optional, transitive)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]].
|
||||
*/
|
||||
|
||||
// DO NOT EDIT MANUALLY
|
||||
package lmcoursier.definitions
|
||||
/**
|
||||
* @param exclude Use "*" in either organization or name to match any.
|
||||
* @param include Use "*" in either organization or name to match any.
|
||||
*/
|
||||
final class ModuleMatchers private (
|
||||
val exclude: Set[lmcoursier.definitions.Module],
|
||||
val include: Set[lmcoursier.definitions.Module]) extends Serializable {
|
||||
|
||||
|
||||
|
||||
override def equals(o: Any): Boolean = o match {
|
||||
case x: ModuleMatchers => (this.exclude == x.exclude) && (this.include == x.include)
|
||||
case _ => false
|
||||
}
|
||||
override def hashCode: Int = {
|
||||
37 * (37 * (37 * (17 + "lmcoursier.definitions.ModuleMatchers".##) + exclude.##) + include.##)
|
||||
}
|
||||
override def toString: String = {
|
||||
"ModuleMatchers(" + exclude + ", " + include + ")"
|
||||
}
|
||||
private[this] def copy(exclude: Set[lmcoursier.definitions.Module] = exclude, include: Set[lmcoursier.definitions.Module] = include): ModuleMatchers = {
|
||||
new ModuleMatchers(exclude, include)
|
||||
}
|
||||
def withExclude(exclude: Set[lmcoursier.definitions.Module]): ModuleMatchers = {
|
||||
copy(exclude = exclude)
|
||||
}
|
||||
def withInclude(include: Set[lmcoursier.definitions.Module]): ModuleMatchers = {
|
||||
copy(include = include)
|
||||
}
|
||||
}
|
||||
object ModuleMatchers {
|
||||
/** ModuleMatchers that matches to any modules. */
|
||||
def all: ModuleMatchers = ModuleMatchers(Set.empty, Set.empty)
|
||||
def apply(exclude: Set[lmcoursier.definitions.Module], include: Set[lmcoursier.definitions.Module]): ModuleMatchers = new ModuleMatchers(exclude, include)
|
||||
}
|
||||
|
|
@ -9,9 +9,9 @@ final class Publication private (
|
|||
val `type`: Type,
|
||||
val ext: Extension,
|
||||
val classifier: Classifier) extends Serializable {
|
||||
def attributes: Attributes = Attributes(`type`, classifier)
|
||||
def withAttributes(attributes: Attributes): Publication = withType(attributes.`type`).withClassifier(attributes.classifier)
|
||||
|
||||
def attributes: Attributes =
|
||||
Attributes(`type`, classifier)
|
||||
|
||||
override def equals(o: Any): Boolean = o match {
|
||||
case x: Publication => (this.name == x.name) && (this.`type` == x.`type`) && (this.ext == x.ext) && (this.classifier == x.classifier)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]].
|
||||
*/
|
||||
|
||||
// DO NOT EDIT MANUALLY
|
||||
package lmcoursier.definitions
|
||||
sealed abstract class Reconciliation extends Serializable
|
||||
object Reconciliation {
|
||||
|
||||
|
||||
case object Default extends Reconciliation
|
||||
case object Relaxed extends Reconciliation
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
package lmcoursier.definitions
|
||||
|
||||
import coursier.util.ModuleMatcher
|
||||
import lmcoursier.credentials.{Credentials, DirectCredentials, FileCredentials}
|
||||
|
||||
// TODO Make private[lmcoursier]
|
||||
|
|
@ -36,6 +35,26 @@ object ToCoursier {
|
|||
module.attributes
|
||||
)
|
||||
|
||||
def moduleMatchers(matcher: ModuleMatchers): coursier.util.ModuleMatchers =
|
||||
coursier.util.ModuleMatchers(
|
||||
exclude = matcher.exclude map { x =>
|
||||
coursier.util.ModuleMatcher(module(x))
|
||||
},
|
||||
include = matcher.include map { x =>
|
||||
coursier.util.ModuleMatcher(module(x))
|
||||
}
|
||||
)
|
||||
|
||||
def reconciliation(r: Reconciliation): coursier.core.Reconciliation =
|
||||
r match {
|
||||
case Reconciliation.Default => coursier.core.Reconciliation.Default
|
||||
case Reconciliation.Relaxed => coursier.core.Reconciliation.Relaxed
|
||||
}
|
||||
|
||||
def reconciliation(rs: Vector[(ModuleMatchers, Reconciliation)]):
|
||||
Vector[(coursier.util.ModuleMatchers, coursier.core.Reconciliation)] =
|
||||
rs map { case (m, r) => (moduleMatchers(m), reconciliation(r)) }
|
||||
|
||||
def dependency(dependency: Dependency): coursier.core.Dependency =
|
||||
coursier.core.Dependency(
|
||||
module(dependency.module),
|
||||
|
|
@ -147,12 +166,11 @@ object ToCoursier {
|
|||
def strict(strict: Strict): coursier.params.rule.Strict =
|
||||
coursier.params.rule.Strict(
|
||||
include = strict.include.map {
|
||||
case (o, n) => ModuleMatcher(coursier.Module(coursier.Organization(o), coursier.ModuleName(n)))
|
||||
case (o, n) => coursier.util.ModuleMatcher(coursier.Module(coursier.Organization(o), coursier.ModuleName(n)))
|
||||
},
|
||||
exclude = strict.exclude.map {
|
||||
case (o, n) => ModuleMatcher(coursier.Module(coursier.Organization(o), coursier.ModuleName(n)))
|
||||
case (o, n) => coursier.util.ModuleMatcher(coursier.Module(coursier.Organization(o), coursier.ModuleName(n)))
|
||||
},
|
||||
// ignoreIfForcedVersion = strict.ignoreIfForcedVersion // should be around once the coursier version is bumped
|
||||
)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package coursier.sbtcoursiershared
|
||||
|
||||
import lmcoursier.definitions.{Attributes, Classifier, Configuration, Dependency, Info, Module, ModuleName, Organization, Project, Strict, Type}
|
||||
import lmcoursier.definitions.{Attributes, Classifier, Configuration, Dependency, Extension, Info, Module, ModuleName, Organization, Project, Publication, Strict, Type}
|
||||
import lmcoursier.{FallbackDependency, FromSbt, Inputs}
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport._
|
||||
import coursier.sbtcoursiershared.Structure._
|
||||
|
|
@ -109,33 +109,33 @@ object InputsTasks {
|
|||
.toVector
|
||||
.flatMap(Inputs.ivyXmlMappings)
|
||||
|
||||
def dependency(conf: Configuration, attr: Attributes) = Dependency(
|
||||
def dependency(conf: Configuration, pub: Publication) = Dependency(
|
||||
module,
|
||||
id.getRevision,
|
||||
conf,
|
||||
exclusions,
|
||||
attr,
|
||||
pub,
|
||||
optional = false,
|
||||
desc.isTransitive
|
||||
)
|
||||
|
||||
val attributes: Configuration => Attributes = {
|
||||
val publications: Configuration => Publication = {
|
||||
|
||||
val artifacts = desc.getAllDependencyArtifacts
|
||||
|
||||
val m = artifacts.toVector.flatMap { art =>
|
||||
val attr = Attributes(Type(art.getType), Classifier(""))
|
||||
val pub = Publication(art.getName, Type(art.getType), Extension(art.getExt), Classifier(""))
|
||||
art.getConfigurations.map(Configuration(_)).toVector.map { conf =>
|
||||
conf -> attr
|
||||
conf -> pub
|
||||
}
|
||||
}.toMap
|
||||
|
||||
c => m.getOrElse(c, Attributes(Type(""), Classifier("")))
|
||||
c => m.getOrElse(c, Publication("", Type(""), Extension(""), Classifier("")))
|
||||
}
|
||||
|
||||
configurations.map {
|
||||
case (from, to) =>
|
||||
from -> dependency(to, attributes(to))
|
||||
from -> dependency(to, publications(to))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ plugins_(
|
|||
"io.get-coursier" % "sbt-coursier" % sbtCoursierVersion,
|
||||
"com.typesafe" % "sbt-mima-plugin" % "0.3.0",
|
||||
"com.jsuereth" % "sbt-pgp" % "1.1.2",
|
||||
"io.get-coursier" % "sbt-shading" % sbtCoursierVersion
|
||||
// "org.scala-sbt" % "sbt-contraband" % "0.4.3"
|
||||
"io.get-coursier" % "sbt-shading" % sbtCoursierVersion,
|
||||
"org.scala-sbt" % "sbt-contraband" % "0.4.4"
|
||||
)
|
||||
|
||||
libs ++= Seq(
|
||||
|
|
|
|||
Loading…
Reference in New Issue