diff --git a/build.sbt b/build.sbt index 15255a2af..de633ca50 100644 --- a/build.sbt +++ b/build.sbt @@ -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 } ) diff --git a/modules/lm-coursier/src/main/contraband-scala/coursier/lmcoursier/CoursierConfiguration.scala b/modules/lm-coursier/src/main/contraband-scala/coursier/lmcoursier/CoursierConfiguration.scala index 138d8d99a..3b00506cc 100644 --- a/modules/lm-coursier/src/main/contraband-scala/coursier/lmcoursier/CoursierConfiguration.scala +++ b/modules/lm-coursier/src/main/contraband-scala/coursier/lmcoursier/CoursierConfiguration.scala @@ -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) } diff --git a/modules/lm-coursier/src/main/contraband/lm-coursier.json b/modules/lm-coursier/src/main/contraband/lm-coursier.json index b86485a59..168fab4eb 100644 --- a/modules/lm-coursier/src/main/contraband/lm-coursier.json +++ b/modules/lm-coursier/src/main/contraband/lm-coursier.json @@ -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" } ] } diff --git a/modules/lm-coursier/src/main/scala/coursier/lmcoursier/CoursierDependencyResolution.scala b/modules/lm-coursier/src/main/scala/coursier/lmcoursier/CoursierDependencyResolution.scala index 6698042cd..a166274e6 100644 --- a/modules/lm-coursier/src/main/scala/coursier/lmcoursier/CoursierDependencyResolution.scala +++ b/modules/lm-coursier/src/main/scala/coursier/lmcoursier/CoursierDependencyResolution.scala @@ -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, diff --git a/modules/sbt-coursier/src/sbt-test/sbt-coursier-group-1/inter-project/a/src/main/scala/A.scala b/modules/sbt-coursier/src/sbt-test/shared-1/inter-project/a/src/main/scala/A.scala similarity index 100% rename from modules/sbt-coursier/src/sbt-test/sbt-coursier-group-1/inter-project/a/src/main/scala/A.scala rename to modules/sbt-coursier/src/sbt-test/shared-1/inter-project/a/src/main/scala/A.scala diff --git a/modules/sbt-coursier/src/sbt-test/sbt-coursier-group-1/inter-project/b/src/main/scala/Main.scala b/modules/sbt-coursier/src/sbt-test/shared-1/inter-project/b/src/main/scala/Main.scala similarity index 100% rename from modules/sbt-coursier/src/sbt-test/sbt-coursier-group-1/inter-project/b/src/main/scala/Main.scala rename to modules/sbt-coursier/src/sbt-test/shared-1/inter-project/b/src/main/scala/Main.scala diff --git a/modules/sbt-coursier/src/sbt-test/sbt-coursier-group-1/inter-project/build.sbt b/modules/sbt-coursier/src/sbt-test/shared-1/inter-project/build.sbt similarity index 100% rename from modules/sbt-coursier/src/sbt-test/sbt-coursier-group-1/inter-project/build.sbt rename to modules/sbt-coursier/src/sbt-test/shared-1/inter-project/build.sbt diff --git a/modules/sbt-coursier/src/sbt-test/sbt-coursier-group-1/inter-project/project/plugins.sbt b/modules/sbt-coursier/src/sbt-test/shared-1/inter-project/project/plugins.sbt similarity index 100% rename from modules/sbt-coursier/src/sbt-test/sbt-coursier-group-1/inter-project/project/plugins.sbt rename to modules/sbt-coursier/src/sbt-test/shared-1/inter-project/project/plugins.sbt diff --git a/modules/sbt-coursier/src/sbt-test/sbt-coursier-group-1/inter-project/test b/modules/sbt-coursier/src/sbt-test/shared-1/inter-project/test similarity index 100% rename from modules/sbt-coursier/src/sbt-test/sbt-coursier-group-1/inter-project/test rename to modules/sbt-coursier/src/sbt-test/shared-1/inter-project/test diff --git a/modules/sbt-lm-coursier/src/main/scala/coursier/sbtlmcoursier/LmCoursierPlugin.scala b/modules/sbt-lm-coursier/src/main/scala/coursier/sbtlmcoursier/LmCoursierPlugin.scala index 86dcc8d07..31d04c0f7 100644 --- a/modules/sbt-lm-coursier/src/main/scala/coursier/sbtlmcoursier/LmCoursierPlugin.scala +++ b/modules/sbt-lm-coursier/src/main/scala/coursier/sbtlmcoursier/LmCoursierPlugin.scala @@ -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]] =