mirror of https://github.com/sbt/sbt.git
Take excludeDependency setting into account in sbt-lm-coursier
This commit is contained in:
parent
6cd9b7e2b4
commit
2dc37ab4bc
|
|
@ -14,22 +14,23 @@ final class CoursierConfiguration private (
|
|||
val sbtScalaOrganization: Option[String],
|
||||
val sbtScalaVersion: Option[String],
|
||||
val sbtScalaJars: Vector[java.io.File],
|
||||
val interProjectDependencies: Vector[coursier.core.Project]) extends Serializable {
|
||||
val interProjectDependencies: Vector[coursier.core.Project],
|
||||
val excludeDependencies: Vector[(String, String)]) extends Serializable {
|
||||
|
||||
private def this() = this(None, sbt.librarymanagement.Resolver.defaults, Vector.empty, true, 6, 100, None, None, Vector.empty, Vector.empty)
|
||||
private def this() = this(None, sbt.librarymanagement.Resolver.defaults, Vector.empty, true, 6, 100, None, None, Vector.empty, Vector.empty, Vector.empty)
|
||||
|
||||
override def equals(o: Any): Boolean = o match {
|
||||
case x: CoursierConfiguration => (this.log == x.log) && (this.resolvers == x.resolvers) && (this.otherResolvers == x.otherResolvers) && (this.reorderResolvers == x.reorderResolvers) && (this.parallelDownloads == x.parallelDownloads) && (this.maxIterations == x.maxIterations) && (this.sbtScalaOrganization == x.sbtScalaOrganization) && (this.sbtScalaVersion == x.sbtScalaVersion) && (this.sbtScalaJars == x.sbtScalaJars) && (this.interProjectDependencies == x.interProjectDependencies)
|
||||
case x: CoursierConfiguration => (this.log == x.log) && (this.resolvers == x.resolvers) && (this.otherResolvers == x.otherResolvers) && (this.reorderResolvers == x.reorderResolvers) && (this.parallelDownloads == x.parallelDownloads) && (this.maxIterations == x.maxIterations) && (this.sbtScalaOrganization == x.sbtScalaOrganization) && (this.sbtScalaVersion == x.sbtScalaVersion) && (this.sbtScalaJars == x.sbtScalaJars) && (this.interProjectDependencies == x.interProjectDependencies) && (this.excludeDependencies == x.excludeDependencies)
|
||||
case _ => false
|
||||
}
|
||||
override def hashCode: Int = {
|
||||
37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (17 + "coursier.lmcoursier.CoursierConfiguration".##) + log.##) + resolvers.##) + otherResolvers.##) + reorderResolvers.##) + parallelDownloads.##) + maxIterations.##) + sbtScalaOrganization.##) + sbtScalaVersion.##) + sbtScalaJars.##) + interProjectDependencies.##)
|
||||
37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (17 + "coursier.lmcoursier.CoursierConfiguration".##) + log.##) + resolvers.##) + otherResolvers.##) + reorderResolvers.##) + parallelDownloads.##) + maxIterations.##) + sbtScalaOrganization.##) + sbtScalaVersion.##) + sbtScalaJars.##) + interProjectDependencies.##) + excludeDependencies.##)
|
||||
}
|
||||
override def toString: String = {
|
||||
"CoursierConfiguration(" + log + ", " + resolvers + ", " + otherResolvers + ", " + reorderResolvers + ", " + parallelDownloads + ", " + maxIterations + ", " + sbtScalaOrganization + ", " + sbtScalaVersion + ", " + sbtScalaJars + ", " + interProjectDependencies + ")"
|
||||
"CoursierConfiguration(" + log + ", " + resolvers + ", " + otherResolvers + ", " + reorderResolvers + ", " + parallelDownloads + ", " + maxIterations + ", " + sbtScalaOrganization + ", " + sbtScalaVersion + ", " + sbtScalaJars + ", " + interProjectDependencies + ", " + excludeDependencies + ")"
|
||||
}
|
||||
private[this] def copy(log: Option[xsbti.Logger] = log, resolvers: Vector[sbt.librarymanagement.Resolver] = resolvers, otherResolvers: Vector[sbt.librarymanagement.Resolver] = otherResolvers, reorderResolvers: Boolean = reorderResolvers, parallelDownloads: Int = parallelDownloads, maxIterations: Int = maxIterations, sbtScalaOrganization: Option[String] = sbtScalaOrganization, sbtScalaVersion: Option[String] = sbtScalaVersion, sbtScalaJars: Vector[java.io.File] = sbtScalaJars, interProjectDependencies: Vector[coursier.core.Project] = interProjectDependencies): CoursierConfiguration = {
|
||||
new CoursierConfiguration(log, resolvers, otherResolvers, reorderResolvers, parallelDownloads, maxIterations, sbtScalaOrganization, sbtScalaVersion, sbtScalaJars, interProjectDependencies)
|
||||
private[this] def copy(log: Option[xsbti.Logger] = log, resolvers: Vector[sbt.librarymanagement.Resolver] = resolvers, otherResolvers: Vector[sbt.librarymanagement.Resolver] = otherResolvers, reorderResolvers: Boolean = reorderResolvers, parallelDownloads: Int = parallelDownloads, maxIterations: Int = maxIterations, sbtScalaOrganization: Option[String] = sbtScalaOrganization, sbtScalaVersion: Option[String] = sbtScalaVersion, sbtScalaJars: Vector[java.io.File] = sbtScalaJars, interProjectDependencies: Vector[coursier.core.Project] = interProjectDependencies, excludeDependencies: Vector[(String, String)] = excludeDependencies): CoursierConfiguration = {
|
||||
new CoursierConfiguration(log, resolvers, otherResolvers, reorderResolvers, parallelDownloads, maxIterations, sbtScalaOrganization, sbtScalaVersion, sbtScalaJars, interProjectDependencies, excludeDependencies)
|
||||
}
|
||||
def withLog(log: Option[xsbti.Logger]): CoursierConfiguration = {
|
||||
copy(log = log)
|
||||
|
|
@ -70,10 +71,13 @@ final class CoursierConfiguration private (
|
|||
def withInterProjectDependencies(interProjectDependencies: Vector[coursier.core.Project]): CoursierConfiguration = {
|
||||
copy(interProjectDependencies = interProjectDependencies)
|
||||
}
|
||||
def withExcludeDependencies(excludeDependencies: Vector[(String, String)]): CoursierConfiguration = {
|
||||
copy(excludeDependencies = excludeDependencies)
|
||||
}
|
||||
}
|
||||
object CoursierConfiguration {
|
||||
|
||||
def apply(): CoursierConfiguration = new CoursierConfiguration()
|
||||
def apply(log: Option[xsbti.Logger], resolvers: Vector[sbt.librarymanagement.Resolver], otherResolvers: Vector[sbt.librarymanagement.Resolver], reorderResolvers: Boolean, parallelDownloads: Int, maxIterations: Int, sbtScalaOrganization: Option[String], sbtScalaVersion: Option[String], sbtScalaJars: Vector[java.io.File], interProjectDependencies: Vector[coursier.core.Project]): CoursierConfiguration = new CoursierConfiguration(log, resolvers, otherResolvers, reorderResolvers, parallelDownloads, maxIterations, sbtScalaOrganization, sbtScalaVersion, sbtScalaJars, interProjectDependencies)
|
||||
def apply(log: xsbti.Logger, resolvers: Vector[sbt.librarymanagement.Resolver], otherResolvers: Vector[sbt.librarymanagement.Resolver], reorderResolvers: Boolean, parallelDownloads: Int, maxIterations: Int, sbtScalaOrganization: String, sbtScalaVersion: String, sbtScalaJars: Vector[java.io.File], interProjectDependencies: Vector[coursier.core.Project]): CoursierConfiguration = new CoursierConfiguration(Option(log), resolvers, otherResolvers, reorderResolvers, parallelDownloads, maxIterations, Option(sbtScalaOrganization), Option(sbtScalaVersion), sbtScalaJars, interProjectDependencies)
|
||||
def apply(log: Option[xsbti.Logger], resolvers: Vector[sbt.librarymanagement.Resolver], otherResolvers: Vector[sbt.librarymanagement.Resolver], reorderResolvers: Boolean, parallelDownloads: Int, maxIterations: Int, sbtScalaOrganization: Option[String], sbtScalaVersion: Option[String], sbtScalaJars: Vector[java.io.File], interProjectDependencies: Vector[coursier.core.Project], excludeDependencies: Vector[(String, String)]): CoursierConfiguration = new CoursierConfiguration(log, resolvers, otherResolvers, reorderResolvers, parallelDownloads, maxIterations, sbtScalaOrganization, sbtScalaVersion, sbtScalaJars, interProjectDependencies, excludeDependencies)
|
||||
def apply(log: xsbti.Logger, resolvers: Vector[sbt.librarymanagement.Resolver], otherResolvers: Vector[sbt.librarymanagement.Resolver], reorderResolvers: Boolean, parallelDownloads: Int, maxIterations: Int, sbtScalaOrganization: String, sbtScalaVersion: String, sbtScalaJars: Vector[java.io.File], interProjectDependencies: Vector[coursier.core.Project], excludeDependencies: Vector[(String, String)]): CoursierConfiguration = new CoursierConfiguration(Option(log), resolvers, otherResolvers, reorderResolvers, parallelDownloads, maxIterations, Option(sbtScalaOrganization), Option(sbtScalaVersion), sbtScalaJars, interProjectDependencies, excludeDependencies)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,12 @@
|
|||
"type": "coursier.core.Project*",
|
||||
"default": "Vector.empty",
|
||||
"since": "0.0.1"
|
||||
},
|
||||
{
|
||||
"name": "excludeDependencies",
|
||||
"type": "(String, String)*",
|
||||
"default": "Vector.empty",
|
||||
"since": "0.0.1"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ package coursier.lmcoursier
|
|||
|
||||
import java.io.{File, OutputStreamWriter}
|
||||
|
||||
import _root_.coursier.{Artifact, Cache, CachePolicy, FileError, Organization, Project, Resolution, TermDisplay, organizationString}
|
||||
import _root_.coursier.core.Configuration
|
||||
import _root_.coursier.{Artifact, Cache, CachePolicy, FileError, Organization, Resolution, TermDisplay, organizationString}
|
||||
import _root_.coursier.core.{Configuration, ModuleName}
|
||||
import _root_.coursier.ivy.IvyRepository
|
||||
import sbt.internal.librarymanagement.IvySbt
|
||||
import sbt.librarymanagement._
|
||||
|
|
@ -19,6 +19,14 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
|||
else
|
||||
conf.resolvers
|
||||
|
||||
private lazy val excludeDependencies = conf
|
||||
.excludeDependencies
|
||||
.map {
|
||||
case (strOrg, strName) =>
|
||||
(Organization(strOrg), ModuleName(strName))
|
||||
}
|
||||
.toSet
|
||||
|
||||
def moduleDescriptor(moduleSetting: ModuleDescriptorConfiguration): CoursierModuleDescriptor =
|
||||
CoursierModuleDescriptor(moduleSetting, conf)
|
||||
|
||||
|
|
@ -89,11 +97,20 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
|||
|
||||
val internalRepositories = globalPluginsRepos :+ interProjectRepo
|
||||
|
||||
val dependencies = module0.dependencies.flatMap { d =>
|
||||
// crossVersion already taken into account, wiping it here
|
||||
val d0 = d.withCrossVersion(CrossVersion.Disabled())
|
||||
FromSbt.dependencies(d0, sv, sbv)
|
||||
}
|
||||
val dependencies = module0
|
||||
.dependencies
|
||||
.flatMap { d =>
|
||||
// crossVersion already taken into account, wiping it here
|
||||
val d0 = d.withCrossVersion(CrossVersion.Disabled())
|
||||
FromSbt.dependencies(d0, sv, sbv)
|
||||
}
|
||||
.map {
|
||||
case (config, dep) =>
|
||||
val dep0 = dep.copy(
|
||||
exclusions = dep.exclusions ++ excludeDependencies
|
||||
)
|
||||
(config, dep0)
|
||||
}
|
||||
|
||||
val configGraphs = Inputs.ivyGraphs(
|
||||
Inputs.configExtends(module0.configurations)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
package coursier.sbtlmcoursier
|
||||
|
||||
import coursier.lmcoursier.{CoursierConfiguration, CoursierDependencyResolution}
|
||||
import coursier.lmcoursier.{CoursierConfiguration, CoursierDependencyResolution, Inputs}
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared
|
||||
import sbt.{AutoPlugin, Classpaths, Def, Setting, Task, taskKey}
|
||||
import sbt.KeyRanks.DTask
|
||||
import sbt.Keys.{dependencyResolution, fullResolvers, otherResolvers, streams}
|
||||
import sbt.Keys.{dependencyResolution, excludeDependencies, fullResolvers, otherResolvers, scalaBinaryVersion, scalaVersion, streams}
|
||||
import sbt.librarymanagement.DependencyResolution
|
||||
|
||||
object LmCoursierPlugin extends AutoPlugin {
|
||||
|
|
@ -34,12 +34,27 @@ object LmCoursierPlugin extends AutoPlugin {
|
|||
Def.task {
|
||||
val (rs, other) = (fullResolvers.value.toVector, otherResolvers.value.toVector)
|
||||
val interProjectDependencies = coursierInterProjectDependencies.value
|
||||
val excludeDeps = Inputs.exclusions(
|
||||
excludeDependencies.value,
|
||||
scalaVersion.value,
|
||||
scalaBinaryVersion.value,
|
||||
streams.value.log
|
||||
)
|
||||
val s = streams.value
|
||||
Classpaths.warnResolversConflict(rs ++: other, s.log)
|
||||
CoursierConfiguration()
|
||||
.withResolvers(rs)
|
||||
.withOtherResolvers(other)
|
||||
.withInterProjectDependencies(interProjectDependencies.toVector)
|
||||
.withExcludeDependencies(
|
||||
excludeDeps
|
||||
.toVector
|
||||
.sorted
|
||||
.map {
|
||||
case (o, n) =>
|
||||
(o.value, n.value)
|
||||
}
|
||||
)
|
||||
.withLog(s.log)
|
||||
}
|
||||
private def mkDependencyResolution: Def.Initialize[Task[DependencyResolution]] =
|
||||
|
|
|
|||
Loading…
Reference in New Issue