mirror of https://github.com/sbt/sbt.git
Add inter-project dependency support to sbt-lm-coursier
This commit is contained in:
parent
0225bc5ce7
commit
c5e259f050
|
|
@ -51,7 +51,7 @@ lazy val `sbt-coursier-shared` = project
|
|||
lazy val `sbt-lm-coursier` = project
|
||||
.in(file("modules/sbt-lm-coursier"))
|
||||
.enablePlugins(ScriptedPlugin)
|
||||
.dependsOn(`lm-coursier`)
|
||||
.dependsOn(`sbt-coursier-shared`)
|
||||
.settings(
|
||||
plugin,
|
||||
sbtTestDirectory := sbtTestDirectory.in(`sbt-coursier`).value,
|
||||
|
|
@ -61,6 +61,7 @@ lazy val `sbt-lm-coursier` = project
|
|||
// TODO Get those automatically
|
||||
// (but shouldn't scripted itself handle that…?)
|
||||
publishLocal.in(`lm-coursier`).value
|
||||
publishLocal.in(`sbt-coursier-shared`).value
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -13,22 +13,23 @@ final class CoursierConfiguration private (
|
|||
val maxIterations: Int,
|
||||
val sbtScalaOrganization: Option[String],
|
||||
val sbtScalaVersion: Option[String],
|
||||
val sbtScalaJars: Vector[java.io.File]) extends Serializable {
|
||||
val sbtScalaJars: Vector[java.io.File],
|
||||
val interProjectDependencies: Vector[coursier.core.Project]) extends Serializable {
|
||||
|
||||
private def this() = this(None, sbt.librarymanagement.Resolver.defaults, Vector.empty, true, 6, 100, None, None, Vector.empty)
|
||||
private def this() = this(None, sbt.librarymanagement.Resolver.defaults, Vector.empty, true, 6, 100, None, None, 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)
|
||||
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 _ => false
|
||||
}
|
||||
override def hashCode: Int = {
|
||||
37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (17 + "coursier.lmcoursier.CoursierConfiguration".##) + log.##) + resolvers.##) + otherResolvers.##) + reorderResolvers.##) + parallelDownloads.##) + maxIterations.##) + sbtScalaOrganization.##) + sbtScalaVersion.##) + sbtScalaJars.##)
|
||||
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.##)
|
||||
}
|
||||
override def toString: String = {
|
||||
"CoursierConfiguration(" + log + ", " + resolvers + ", " + otherResolvers + ", " + reorderResolvers + ", " + parallelDownloads + ", " + maxIterations + ", " + sbtScalaOrganization + ", " + sbtScalaVersion + ", " + sbtScalaJars + ")"
|
||||
"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): CoursierConfiguration = {
|
||||
new CoursierConfiguration(log, resolvers, otherResolvers, reorderResolvers, parallelDownloads, maxIterations, sbtScalaOrganization, sbtScalaVersion, sbtScalaJars)
|
||||
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)
|
||||
}
|
||||
def withLog(log: Option[xsbti.Logger]): CoursierConfiguration = {
|
||||
copy(log = log)
|
||||
|
|
@ -66,10 +67,13 @@ final class CoursierConfiguration private (
|
|||
def withSbtScalaJars(sbtScalaJars: Vector[java.io.File]): CoursierConfiguration = {
|
||||
copy(sbtScalaJars = sbtScalaJars)
|
||||
}
|
||||
def withInterProjectDependencies(interProjectDependencies: Vector[coursier.core.Project]): CoursierConfiguration = {
|
||||
copy(interProjectDependencies = interProjectDependencies)
|
||||
}
|
||||
}
|
||||
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]): CoursierConfiguration = new CoursierConfiguration(log, resolvers, otherResolvers, reorderResolvers, parallelDownloads, maxIterations, sbtScalaOrganization, sbtScalaVersion, sbtScalaJars)
|
||||
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]): CoursierConfiguration = new CoursierConfiguration(Option(log), resolvers, otherResolvers, reorderResolvers, parallelDownloads, maxIterations, Option(sbtScalaOrganization), Option(sbtScalaVersion), sbtScalaJars)
|
||||
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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,12 @@
|
|||
"type": "java.io.File*",
|
||||
"default": "Vector.empty",
|
||||
"since": "0.0.1"
|
||||
},
|
||||
{
|
||||
"name": "interProjectDependencies",
|
||||
"type": "coursier.core.Project*",
|
||||
"default": "Vector.empty",
|
||||
"since": "0.0.1"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,8 +85,7 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
|||
withArtifacts = false
|
||||
)
|
||||
|
||||
val interProjectDependencies: Seq[Project] = Nil // TODO Don't use Nil here
|
||||
val interProjectRepo = InterProjectRepository(interProjectDependencies)
|
||||
val interProjectRepo = InterProjectRepository(conf.interProjectDependencies)
|
||||
|
||||
val internalRepositories = globalPluginsRepos :+ interProjectRepo
|
||||
|
||||
|
|
@ -107,7 +106,7 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
|||
autoScalaLib = true,
|
||||
mainRepositories = mainRepositories,
|
||||
parentProjectCache = Map.empty,
|
||||
interProjectDependencies = interProjectDependencies,
|
||||
interProjectDependencies = conf.interProjectDependencies,
|
||||
internalRepositories = internalRepositories,
|
||||
userEnabledProfiles = Set.empty,
|
||||
userForceVersions = Map.empty,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package coursier.sbtlmcoursier
|
||||
|
||||
import coursier.lmcoursier.{CoursierConfiguration, CoursierDependencyResolution}
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared
|
||||
import sbt.{AutoPlugin, Classpaths, Def, Task, taskKey}
|
||||
import sbt.KeyRanks.DTask
|
||||
import sbt.Keys.{dependencyResolution, fullResolvers, otherResolvers, streams}
|
||||
|
|
@ -13,12 +14,14 @@ object LmCoursierPlugin extends AutoPlugin {
|
|||
}
|
||||
|
||||
import autoImport._
|
||||
import SbtCoursierShared.autoImport._
|
||||
|
||||
|
||||
override def trigger = allRequirements
|
||||
|
||||
// requiring IvyPlugin… to override it, and so that it doesn't override us :|
|
||||
override def requires = sbt.plugins.IvyPlugin
|
||||
// this transitively requires IvyPlugin… which is needed to override it,
|
||||
// so that it doesn't override us :|
|
||||
override def requires = SbtCoursierShared
|
||||
|
||||
// putting this in projectSettings like sbt.plugins.IvyPlugin does :|
|
||||
override def projectSettings = Seq(
|
||||
|
|
@ -30,11 +33,13 @@ object LmCoursierPlugin extends AutoPlugin {
|
|||
private def mkCoursierConfiguration: Def.Initialize[Task[CoursierConfiguration]] =
|
||||
Def.task {
|
||||
val (rs, other) = (fullResolvers.value.toVector, otherResolvers.value.toVector)
|
||||
val interProjectDependencies = coursierInterProjectDependencies.value
|
||||
val s = streams.value
|
||||
Classpaths.warnResolversConflict(rs ++: other, s.log)
|
||||
CoursierConfiguration()
|
||||
.withResolvers(rs)
|
||||
.withOtherResolvers(other)
|
||||
.withInterProjectDependencies(interProjectDependencies.toVector)
|
||||
.withLog(s.log)
|
||||
}
|
||||
private def mkDependencyResolution: Def.Initialize[Task[DependencyResolution]] =
|
||||
|
|
|
|||
Loading…
Reference in New Issue