mirror of
https://github.com/sbt/sbt.git
synced 2026-08-22 06:07:24 +02:00
Formatting / styling
This commit is contained in:
@@ -36,25 +36,35 @@ object Resolution {
|
|||||||
def key(dep: Dependency): Key =
|
def key(dep: Dependency): Key =
|
||||||
(dep.module.organization, dep.module.name, dep.attributes.`type`)
|
(dep.module.organization, dep.module.name, dep.attributes.`type`)
|
||||||
|
|
||||||
def add(dict: Map[Key, Dependency], dep: Dependency): Map[Key, Dependency] = {
|
def add(
|
||||||
|
dict: Map[Key, Dependency],
|
||||||
|
dep: Dependency
|
||||||
|
): Map[Key, Dependency] = {
|
||||||
|
|
||||||
val key0 = key(dep)
|
val key0 = key(dep)
|
||||||
|
|
||||||
if (dict.contains(key0))
|
if (dict.contains(key0))
|
||||||
dict
|
dict
|
||||||
else
|
else
|
||||||
dict + (key0 -> dep)
|
dict + (key0 -> dep)
|
||||||
}
|
}
|
||||||
|
|
||||||
def addSeq(dict: Map[Key, Dependency], deps: Seq[Dependency]): Map[Key, Dependency] =
|
def addSeq(
|
||||||
|
dict: Map[Key, Dependency],
|
||||||
|
deps: Seq[Dependency]
|
||||||
|
): Map[Key, Dependency] =
|
||||||
(dict /: deps)(add)
|
(dict /: deps)(add)
|
||||||
}
|
}
|
||||||
|
|
||||||
def mergeProperties(dict: Map[String, String], other: Map[String, String]): Map[String, String] = {
|
def mergeProperties(
|
||||||
|
dict: Map[String, String],
|
||||||
|
other: Map[String, String]
|
||||||
|
): Map[String, String] =
|
||||||
dict ++ other.filterKeys(!dict.contains(_))
|
dict ++ other.filterKeys(!dict.contains(_))
|
||||||
}
|
|
||||||
|
|
||||||
def addDependencies(deps: Seq[Seq[Dependency]]): Seq[Dependency] = {
|
def addDependencies(deps: Seq[Seq[Dependency]]): Seq[Dependency] = {
|
||||||
val res =
|
val res =
|
||||||
deps.foldRight((Set.empty[DepMgmt.Key], Seq.empty[Dependency])) {
|
(deps :\ (Set.empty[DepMgmt.Key], Seq.empty[Dependency])) {
|
||||||
case (deps0, (set, acc)) =>
|
case (deps0, (set, acc)) =>
|
||||||
val deps = deps0
|
val deps = deps0
|
||||||
.filter(dep => !set(DepMgmt.key(dep)))
|
.filter(dep => !set(DepMgmt.key(dep)))
|
||||||
@@ -65,7 +75,9 @@ object Resolution {
|
|||||||
res._2
|
res._2
|
||||||
}
|
}
|
||||||
|
|
||||||
val propRegex = (quote("${") + "([a-zA-Z0-9-.]*)" + quote("}")).r
|
val propRegex = (
|
||||||
|
quote("${") + "([a-zA-Z0-9-.]*)" + quote("}")
|
||||||
|
).r
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Substitutes `properties` in `dependencies`.
|
* Substitutes `properties` in `dependencies`.
|
||||||
@@ -108,15 +120,19 @@ object Resolution {
|
|||||||
),
|
),
|
||||||
scope = Parse.scope(substituteProps(dep.scope.name)),
|
scope = Parse.scope(substituteProps(dep.scope.name)),
|
||||||
exclusions = dep.exclusions
|
exclusions = dep.exclusions
|
||||||
.map{case (org, name) => (substituteProps(org), substituteProps(name))}
|
.map{case (org, name) =>
|
||||||
// FIXME The content of the optional tag may also be a property in the original POM.
|
(substituteProps(org), substituteProps(name))
|
||||||
// Maybe not parse it that earlier?
|
}
|
||||||
|
// FIXME The content of the optional tag may also be a property in
|
||||||
|
// the original POM. Maybe not parse it that earlier?
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge several version constraints together. Returns `None` in case of conflict.
|
* Merge several version constraints together.
|
||||||
|
*
|
||||||
|
* Returns `None` in case of conflict.
|
||||||
*/
|
*/
|
||||||
def mergeVersions(versions: Seq[String]): Option[String] = {
|
def mergeVersions(versions: Seq[String]): Option[String] = {
|
||||||
val (nonParsedConstraints, parsedConstraints) =
|
val (nonParsedConstraints, parsedConstraints) =
|
||||||
@@ -126,30 +142,39 @@ object Resolution {
|
|||||||
|
|
||||||
// FIXME Report this in return type, not this way
|
// FIXME Report this in return type, not this way
|
||||||
if (nonParsedConstraints.nonEmpty)
|
if (nonParsedConstraints.nonEmpty)
|
||||||
Console.err.println(s"Ignoring unparsed versions: ${nonParsedConstraints.map(_._1)}")
|
Console.err.println(
|
||||||
|
s"Ignoring unparsed versions: ${nonParsedConstraints.map(_._1)}"
|
||||||
|
)
|
||||||
|
|
||||||
val constraintOpt =
|
val intervalOpt =
|
||||||
(Option(VersionInterval.zero) /: parsedConstraints.map(_._2.get.interval)) {
|
(Option(VersionInterval.zero) /: parsedConstraints) {
|
||||||
case (acc, itv) => acc.flatMap(_.merge(itv))
|
case (acc, (_, someCstr)) =>
|
||||||
} .map(_.constraint)
|
acc.flatMap(_.merge(someCstr.get.interval))
|
||||||
|
}
|
||||||
|
|
||||||
constraintOpt.map(_.repr)
|
intervalOpt
|
||||||
|
.map(_.constraint.repr)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge several dependencies, solving version constraints of duplicated modules.
|
* Merge several dependencies, solving version constraints of duplicated
|
||||||
* Returns the conflicted dependencies, and the (merged) others.
|
* modules.
|
||||||
|
*
|
||||||
|
* Returns the conflicted dependencies, and the merged others.
|
||||||
*/
|
*/
|
||||||
def merge(
|
def merge(
|
||||||
dependencies: TraversableOnce[Dependency]
|
dependencies: TraversableOnce[Dependency]
|
||||||
): (Seq[Dependency], Seq[Dependency]) = {
|
): (Seq[Dependency], Seq[Dependency]) = {
|
||||||
|
|
||||||
val mergedByModVer = dependencies
|
val mergedByModVer = dependencies
|
||||||
.toList
|
.toList
|
||||||
.groupBy(dep => dep.module)
|
.groupBy(dep => dep.module)
|
||||||
.mapValues { deps =>
|
.mapValues { deps =>
|
||||||
if (deps.lengthCompare(1) == 0) \/-(deps)
|
if (deps.lengthCompare(1) == 0) \/-(deps)
|
||||||
else {
|
else {
|
||||||
val versions = deps.map(_.version).distinct
|
val versions = deps
|
||||||
|
.map(_.version)
|
||||||
|
.distinct
|
||||||
val versionOpt = mergeVersions(versions)
|
val versionOpt = mergeVersions(versions)
|
||||||
|
|
||||||
versionOpt match {
|
versionOpt match {
|
||||||
@@ -161,7 +186,9 @@ object Resolution {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val merged = mergedByModVer.values.toList
|
val merged = mergedByModVer
|
||||||
|
.values
|
||||||
|
.toList
|
||||||
|
|
||||||
(
|
(
|
||||||
merged
|
merged
|
||||||
@@ -174,8 +201,9 @@ object Resolution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If one of our dependency has scope `base`, and a transitive dependency of it has scope `transitive`,
|
* If one of our dependency has scope `base`, and a transitive
|
||||||
* return the scope of the latter for us, if any. If empty, means the transitive dependency
|
* dependency of it has scope `transitive`, return the scope of
|
||||||
|
* the latter for us, if any. If empty, means the transitive dependency
|
||||||
* should not be considered a dependency for us.
|
* should not be considered a dependency for us.
|
||||||
*
|
*
|
||||||
* See https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope.
|
* See https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope.
|
||||||
@@ -185,16 +213,17 @@ object Resolution {
|
|||||||
transitive: Scope
|
transitive: Scope
|
||||||
): Option[Scope] =
|
): Option[Scope] =
|
||||||
(base, transitive) match {
|
(base, transitive) match {
|
||||||
case (other, Scope.Compile) => Some(other)
|
case (other, Scope.Compile) => Some(other)
|
||||||
case (Scope.Compile, Scope.Runtime) => Some(Scope.Runtime)
|
case (Scope.Compile, Scope.Runtime) => Some(Scope.Runtime)
|
||||||
case (other, Scope.Runtime) => Some(other)
|
case (other, Scope.Runtime) => Some(other)
|
||||||
case _ => None
|
case _ => None
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies `dependencyManagement` to `dependencies`.
|
* Applies `dependencyManagement` to `dependencies`.
|
||||||
*
|
*
|
||||||
* Fill empty version / scope / exclusions, for dependencies found in `dependencyManagement`.
|
* Fill empty version / scope / exclusions, for dependencies found in
|
||||||
|
* `dependencyManagement`.
|
||||||
*/
|
*/
|
||||||
def depsWithDependencyManagement(
|
def depsWithDependencyManagement(
|
||||||
dependencies: Seq[Dependency],
|
dependencies: Seq[Dependency],
|
||||||
@@ -243,31 +272,34 @@ object Resolution {
|
|||||||
dependencies
|
dependencies
|
||||||
.filter(dep => filter(dep.module.organization, dep.module.name))
|
.filter(dep => filter(dep.module.organization, dep.module.name))
|
||||||
.map(dep =>
|
.map(dep =>
|
||||||
dep.copy(exclusions = Exclusions.minimize(dep.exclusions ++ exclusions))
|
dep.copy(
|
||||||
|
exclusions = Exclusions.minimize(dep.exclusions ++ exclusions)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the dependencies of `project`, knowing that it came from dependency `from` (that is,
|
* Get the dependencies of `project`, knowing that it came from dependency
|
||||||
* `from.module == project.module`).
|
* `from` (that is, `from.module == project.module`).
|
||||||
*
|
*
|
||||||
* Substitute properties, update scopes, apply exclusions, and get extra parameters from
|
* Substitute properties, update scopes, apply exclusions, and get extra
|
||||||
* dependency management along the way.
|
* parameters from dependency management along the way.
|
||||||
*/
|
*/
|
||||||
def finalDependencies(
|
def finalDependencies(
|
||||||
from: Dependency,
|
from: Dependency,
|
||||||
project: Project
|
project: Project
|
||||||
): Seq[Dependency] = {
|
): Seq[Dependency] = {
|
||||||
|
|
||||||
// Here, we're substituting properties also in dependencies that come from parents
|
// Here, we're substituting properties also in dependencies that
|
||||||
// or dependency management. This may not be the right thing to do.
|
// come from parents or dependency management. This may not be
|
||||||
|
// the right thing to do.
|
||||||
|
|
||||||
val properties = mergeProperties(
|
val properties = mergeProperties(
|
||||||
project.properties,
|
project.properties,
|
||||||
Map(
|
Map(
|
||||||
"project.groupId" -> project.module.organization,
|
"project.groupId" -> project.module.organization,
|
||||||
"project.artifactId" -> project.module.name,
|
"project.artifactId" -> project.module.name,
|
||||||
"project.version" -> project.version
|
"project.version" -> project.version
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -287,32 +319,42 @@ object Resolution {
|
|||||||
deps
|
deps
|
||||||
.flatMap { trDep =>
|
.flatMap { trDep =>
|
||||||
resolveScope(from.scope, trDep.scope)
|
resolveScope(from.scope, trDep.scope)
|
||||||
.map(scope => trDep.copy(scope = scope, optional = trDep.optional || from.optional))
|
.map(scope =>
|
||||||
|
trDep.copy(
|
||||||
|
scope = scope,
|
||||||
|
optional = trDep.optional || from.optional
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default function checking whether a profile is active, given its id, activation conditions,
|
* Default function checking whether a profile is active, given
|
||||||
* and the properties of its project.
|
* its id, activation conditions, and the properties of its project.
|
||||||
*/
|
*/
|
||||||
def defaultProfileActivation(
|
def defaultProfileActivation(
|
||||||
id: String,
|
id: String,
|
||||||
activation: Activation,
|
activation: Activation,
|
||||||
props: Map[String, String]
|
props: Map[String, String]
|
||||||
): Boolean = {
|
): Boolean =
|
||||||
|
if (activation.properties.isEmpty)
|
||||||
if (activation.properties.isEmpty) false
|
false
|
||||||
else {
|
else
|
||||||
activation.properties.forall { case (name, valueOpt) =>
|
activation
|
||||||
props.get(name).exists{ v =>
|
.properties
|
||||||
valueOpt.forall { reqValue =>
|
.forall {case (name, valueOpt) =>
|
||||||
if (reqValue.startsWith("!")) v != reqValue.drop(1)
|
props
|
||||||
else v == reqValue
|
.get(name)
|
||||||
}
|
.exists{ v =>
|
||||||
|
valueOpt
|
||||||
|
.forall { reqValue =>
|
||||||
|
if (reqValue.startsWith("!"))
|
||||||
|
v != reqValue.drop(1)
|
||||||
|
else
|
||||||
|
v == reqValue
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default dependency filter used during resolution.
|
* Default dependency filter used during resolution.
|
||||||
@@ -362,7 +404,9 @@ case class Resolution(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transitive dependencies of the current dependencies, according to what there currently is in cache.
|
* Transitive dependencies of the current dependencies, according to
|
||||||
|
* what there currently is in cache.
|
||||||
|
*
|
||||||
* No attempt is made to solve version conflicts here.
|
* No attempt is made to solve version conflicts here.
|
||||||
*/
|
*/
|
||||||
def transitiveDependencies: Seq[Dependency] =
|
def transitiveDependencies: Seq[Dependency] =
|
||||||
@@ -371,13 +415,15 @@ case class Resolution(
|
|||||||
.flatMap(finalDependencies0)
|
.flatMap(finalDependencies0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "next" dependency set, made of the current dependencies and their transitive dependencies,
|
* The "next" dependency set, made of the current dependencies and their
|
||||||
* trying to solve version conflicts. Transitive dependencies are calculated with the current cache.
|
* transitive dependencies, trying to solve version conflicts.
|
||||||
|
* Transitive dependencies are calculated with the current cache.
|
||||||
*
|
*
|
||||||
* May contain dependencies added in previous iterations, but no more required. These are filtered below, see
|
* May contain dependencies added in previous iterations, but no more
|
||||||
* `newDependencies`.
|
* required. These are filtered below, see `newDependencies`.
|
||||||
*
|
*
|
||||||
* Returns a tuple made of the conflicting dependencies, and all the dependencies.
|
* Returns a tuple made of the conflicting dependencies, and all
|
||||||
|
* the dependencies.
|
||||||
*/
|
*/
|
||||||
def nextDependenciesAndConflicts: (Seq[Dependency], Seq[Dependency]) =
|
def nextDependenciesAndConflicts: (Seq[Dependency], Seq[Dependency]) =
|
||||||
merge(
|
merge(
|
||||||
@@ -389,8 +435,10 @@ case class Resolution(
|
|||||||
* The modules we miss some info about.
|
* The modules we miss some info about.
|
||||||
*/
|
*/
|
||||||
def missingFromCache: Set[ModuleVersion] = {
|
def missingFromCache: Set[ModuleVersion] = {
|
||||||
val modules = dependencies.map(_.moduleVersion)
|
val modules = dependencies
|
||||||
val nextModules = nextDependenciesAndConflicts._2.map(_.moduleVersion)
|
.map(_.moduleVersion)
|
||||||
|
val nextModules = nextDependenciesAndConflicts._2
|
||||||
|
.map(_.moduleVersion)
|
||||||
|
|
||||||
(modules ++ nextModules)
|
(modules ++ nextModules)
|
||||||
.filterNot(mod => projectCache.contains(mod) || errorCache.contains(mod))
|
.filterNot(mod => projectCache.contains(mod) || errorCache.contains(mod))
|
||||||
@@ -411,10 +459,12 @@ case class Resolution(
|
|||||||
missingFromCache.isEmpty && isFixPoint
|
missingFromCache.isEmpty && isFixPoint
|
||||||
}
|
}
|
||||||
|
|
||||||
private def eraseVersion(dep: Dependency) = dep.copy(version = "")
|
private def eraseVersion(dep: Dependency) =
|
||||||
|
dep.copy(version = "")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a map giving the dependencies that brought each of the dependency of the "next" dependency set.
|
* Returns a map giving the dependencies that brought each of
|
||||||
|
* the dependency of the "next" dependency set.
|
||||||
*
|
*
|
||||||
* The versions of all the dependencies returned are erased (emptied).
|
* The versions of all the dependencies returned are erased (emptied).
|
||||||
*/
|
*/
|
||||||
@@ -481,6 +531,7 @@ case class Resolution(
|
|||||||
*/
|
*/
|
||||||
def newDependencies: Set[Dependency] = {
|
def newDependencies: Set[Dependency] = {
|
||||||
val remainingDependencies0 = remainingDependencies
|
val remainingDependencies0 = remainingDependencies
|
||||||
|
|
||||||
nextDependenciesAndConflicts._2
|
nextDependenciesAndConflicts._2
|
||||||
.filter(dep => remainingDependencies0(eraseVersion(dep)))
|
.filter(dep => remainingDependencies0(eraseVersion(dep)))
|
||||||
.toSet
|
.toSet
|
||||||
@@ -496,8 +547,8 @@ case class Resolution(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If no module info is missing, the next state of the resolution, which can be immediately calculated.
|
* If no module info is missing, the next state of the resolution,
|
||||||
* Else, the current resolution itself.
|
* which can be immediately calculated. Else, the current resolution.
|
||||||
*/
|
*/
|
||||||
@tailrec
|
@tailrec
|
||||||
final def nextIfNoMissing: Resolution = {
|
final def nextIfNoMissing: Resolution = {
|
||||||
@@ -544,12 +595,12 @@ case class Resolution(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Missing modules in cache, to get the full list of dependencies of `project`, taking
|
* Missing modules in cache, to get the full list of dependencies of
|
||||||
* dependency management / inheritance into account.
|
* `project`, taking dependency management / inheritance into account.
|
||||||
*
|
*
|
||||||
* Note that adding the missing modules to the cache may unveil other missing modules, so
|
* Note that adding the missing modules to the cache may unveil other
|
||||||
* these modules should be added to the cache, and `dependencyManagementMissing` checked again
|
* missing modules, so these modules should be added to the cache, and
|
||||||
* for new missing modules.
|
* `dependencyManagementMissing` checked again for new missing modules.
|
||||||
*/
|
*/
|
||||||
def dependencyManagementMissing(project: Project): Set[ModuleVersion] = {
|
def dependencyManagementMissing(project: Project): Set[ModuleVersion] = {
|
||||||
|
|
||||||
@@ -587,9 +638,11 @@ case class Resolution(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add dependency management / inheritance related items to `project`, from what's available in cache.
|
* Add dependency management / inheritance related items to `project`,
|
||||||
* It is recommended to have fetched what `dependencyManagementMissing` returned prior to calling
|
* from what's available in cache.
|
||||||
* `withDependencyManagement`.
|
*
|
||||||
|
* It is recommended to have fetched what `dependencyManagementMissing`
|
||||||
|
* returned prior to calling this.
|
||||||
*/
|
*/
|
||||||
def withDependencyManagement(project: Project): Project = {
|
def withDependencyManagement(project: Project): Project = {
|
||||||
|
|
||||||
@@ -613,12 +666,16 @@ case class Resolution(
|
|||||||
mergeProperties(acc, p.properties)
|
mergeProperties(acc, p.properties)
|
||||||
}
|
}
|
||||||
|
|
||||||
val deps =
|
val deps = (
|
||||||
dependencies0
|
dependencies0
|
||||||
.collect{ case dep if dep.scope == Scope.Import && projectCache.contains(dep.moduleVersion) => dep.moduleVersion } ++
|
.collect { case dep if dep.scope == Scope.Import =>
|
||||||
project.parent.filter(projectCache.contains)
|
dep.moduleVersion
|
||||||
|
} ++
|
||||||
|
project.parent
|
||||||
|
).filter(projectCache.contains)
|
||||||
|
|
||||||
val projs = deps.map(projectCache(_)._2)
|
val projs = deps
|
||||||
|
.map(projectCache(_)._2)
|
||||||
|
|
||||||
val depMgmt = (
|
val depMgmt = (
|
||||||
project.dependencyManagement +: (
|
project.dependencyManagement +: (
|
||||||
@@ -630,8 +687,11 @@ case class Resolution(
|
|||||||
val depsSet = deps.toSet
|
val depsSet = deps.toSet
|
||||||
|
|
||||||
project.copy(
|
project.copy(
|
||||||
dependencies = dependencies0
|
dependencies =
|
||||||
.filterNot(dep => dep.scope == Scope.Import && depsSet(dep.moduleVersion)) ++
|
dependencies0
|
||||||
|
.filterNot(dep =>
|
||||||
|
dep.scope == Scope.Import && depsSet(dep.moduleVersion)
|
||||||
|
) ++
|
||||||
project.parent
|
project.parent
|
||||||
.filter(projectCache.contains)
|
.filter(projectCache.contains)
|
||||||
.toSeq
|
.toSeq
|
||||||
@@ -650,13 +710,18 @@ case class Resolution(
|
|||||||
def artifacts: Seq[Artifact] =
|
def artifacts: Seq[Artifact] =
|
||||||
for {
|
for {
|
||||||
dep <- minDependencies.toSeq
|
dep <- minDependencies.toSeq
|
||||||
(source, proj) <- projectCache.get(dep.moduleVersion).toSeq
|
(source, proj) <- projectCache
|
||||||
artifact <- source.artifacts(dep, proj)
|
.get(dep.moduleVersion)
|
||||||
|
.toSeq
|
||||||
|
artifact <- source
|
||||||
|
.artifacts(dep, proj)
|
||||||
} yield artifact
|
} yield artifact
|
||||||
|
|
||||||
def errors: Seq[(Dependency, Seq[String])] =
|
def errors: Seq[(Dependency, Seq[String])] =
|
||||||
for {
|
for {
|
||||||
dep <- dependencies.toSeq
|
dep <- dependencies.toSeq
|
||||||
err <- errorCache.get(dep.moduleVersion).toSeq
|
err <- errorCache
|
||||||
|
.get(dep.moduleVersion)
|
||||||
|
.toSeq
|
||||||
} yield (dep, err)
|
} yield (dep, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,11 @@ object ResolutionProcess {
|
|||||||
Missing(resolution0.missingFromCache.toSeq, resolution0, apply)
|
Missing(resolution0.missingFromCache.toSeq, resolution0, apply)
|
||||||
}
|
}
|
||||||
|
|
||||||
type FetchResult = Seq[((Module, String), Seq[String] \/ (Artifact.Source, Project))]
|
type FetchResult = Seq[(
|
||||||
|
(Module, String),
|
||||||
|
Seq[String] \/ (Artifact.Source, Project)
|
||||||
|
)]
|
||||||
|
|
||||||
type Fetch[F[_]] = Seq[(Module, String)] => F[FetchResult]
|
type Fetch[F[_]] = Seq[(Module, String)] => F[FetchResult]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,19 +7,31 @@ package object coursier {
|
|||||||
|
|
||||||
type Dependency = core.Dependency
|
type Dependency = core.Dependency
|
||||||
object Dependency {
|
object Dependency {
|
||||||
def apply(module: Module,
|
def apply(
|
||||||
version: String,
|
module: Module,
|
||||||
scope: Scope = Scope.Other(""), // Substituted by Resolver with its own default scope (compile)
|
version: String,
|
||||||
attributes: Attributes = Attributes(),
|
// Substituted by Resolver with its own default scope (compile)
|
||||||
exclusions: Set[(String, String)] = Set.empty,
|
scope: Scope = Scope.Other(""),
|
||||||
optional: Boolean = false): Dependency =
|
attributes: Attributes = Attributes(),
|
||||||
core.Dependency(module, version, scope, attributes, exclusions, optional)
|
exclusions: Set[(String, String)] = Set.empty,
|
||||||
|
optional: Boolean = false
|
||||||
|
): Dependency =
|
||||||
|
core.Dependency(
|
||||||
|
module,
|
||||||
|
version,
|
||||||
|
scope,
|
||||||
|
attributes,
|
||||||
|
exclusions,
|
||||||
|
optional
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Attributes = core.Attributes
|
type Attributes = core.Attributes
|
||||||
object Attributes {
|
object Attributes {
|
||||||
def apply(`type`: String = "jar",
|
def apply(
|
||||||
classifier: String = ""): Attributes =
|
`type`: String = "jar",
|
||||||
|
classifier: String = ""
|
||||||
|
): Attributes =
|
||||||
core.Attributes(`type`, classifier)
|
core.Attributes(`type`, classifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,14 +58,24 @@ package object coursier {
|
|||||||
type Resolution = core.Resolution
|
type Resolution = core.Resolution
|
||||||
object Resolution {
|
object Resolution {
|
||||||
val empty = apply()
|
val empty = apply()
|
||||||
def apply(rootDependencies: Set[Dependency] = Set.empty,
|
def apply(
|
||||||
dependencies: Set[Dependency] = Set.empty,
|
rootDependencies: Set[Dependency] = Set.empty,
|
||||||
conflicts: Set[Dependency] = Set.empty,
|
dependencies: Set[Dependency] = Set.empty,
|
||||||
projectCache: Map[ModuleVersion, (Artifact.Source, Project)] = Map.empty,
|
conflicts: Set[Dependency] = Set.empty,
|
||||||
errorCache: Map[ModuleVersion, Seq[String]] = Map.empty,
|
projectCache: Map[ModuleVersion, (Artifact.Source, Project)] = Map.empty,
|
||||||
filter: Option[Dependency => Boolean] = None,
|
errorCache: Map[ModuleVersion, Seq[String]] = Map.empty,
|
||||||
profileActivation: Option[(String, core.Activation, Map[String, String]) => Boolean] = None): Resolution =
|
filter: Option[Dependency => Boolean] = None,
|
||||||
core.Resolution(rootDependencies, dependencies, conflicts, projectCache, errorCache, filter, profileActivation)
|
profileActivation: Option[(String, core.Activation, Map[String, String]) => Boolean] = None
|
||||||
|
): Resolution =
|
||||||
|
core.Resolution(
|
||||||
|
rootDependencies,
|
||||||
|
dependencies,
|
||||||
|
conflicts,
|
||||||
|
projectCache,
|
||||||
|
errorCache,
|
||||||
|
filter,
|
||||||
|
profileActivation
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Artifact = core.Artifact
|
type Artifact = core.Artifact
|
||||||
@@ -63,18 +85,22 @@ package object coursier {
|
|||||||
val ResolutionProcess: core.ResolutionProcess.type = core.ResolutionProcess
|
val ResolutionProcess: core.ResolutionProcess.type = core.ResolutionProcess
|
||||||
|
|
||||||
implicit class ResolutionExtensions(val underlying: Resolution) extends AnyVal {
|
implicit class ResolutionExtensions(val underlying: Resolution) extends AnyVal {
|
||||||
|
|
||||||
def process: ResolutionProcess = ResolutionProcess(underlying)
|
def process: ResolutionProcess = ResolutionProcess(underlying)
|
||||||
}
|
}
|
||||||
|
|
||||||
implicit def fetch(repositories: Seq[core.Repository]): ResolutionProcess.Fetch[Task] = {
|
implicit def fetch(
|
||||||
|
repositories: Seq[core.Repository]
|
||||||
|
): ResolutionProcess.Fetch[Task] = {
|
||||||
|
|
||||||
modVers =>
|
modVers =>
|
||||||
Task.gatherUnordered(
|
Task.gatherUnordered(
|
||||||
modVers
|
modVers
|
||||||
.map(modVer =>
|
.map {case (module, version) =>
|
||||||
Repository.find(repositories, modVer._1, modVer._2)
|
Repository.find(repositories, module, version)
|
||||||
.run
|
.run
|
||||||
.map(modVer -> _)
|
.map((module, version) -> _)
|
||||||
)
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user