diff --git a/src/main/scala/sbt/ProjectMatrix.scala b/src/main/scala/sbt/ProjectMatrix.scala index 1008eb25a..d98148637 100644 --- a/src/main/scala/sbt/ProjectMatrix.scala +++ b/src/main/scala/sbt/ProjectMatrix.scala @@ -62,14 +62,15 @@ sealed trait ProjectMatrix extends CompositeProject { def jvmPlatform(scalaVersions: Seq[String]): ProjectMatrix def jvmPlatform(scalaVersions: Seq[String], settings: Seq[Setting[_]]): ProjectMatrix - def jvm: ProjectFinder def jsPlatform(scalaVersions: Seq[String]): ProjectMatrix def jsPlatform(scalaVersions: Seq[String], settings: Seq[Setting[_]]): ProjectMatrix - def js: ProjectFinder + def crossLibrary(scalaVersions: Seq[String], suffix: String, settings: Seq[Setting[_]]): ProjectMatrix + def crossLib(suffix: String): ProjectFinder + def projectRefs: Seq[ProjectReference] } @@ -203,15 +204,27 @@ object ProjectMatrix { override def jvmPlatform(scalaVersions: Seq[String], settings: Seq[Setting[_]]): ProjectMatrix = custom(jvmIdSuffix, jvmDirectorySuffix, scalaVersions, { _.settings(settings) }) - override def jsPlatform(scalaVersions: Seq[String]): ProjectMatrix = - jsPlatform(scalaVersions, Nil) - override def jsPlatform(scalaVersions: Seq[String], settings: Seq[Setting[_]]): ProjectMatrix = - custom(jsIdSuffix, jsDirectorySuffix, scalaVersions, { _.settings(settings) }) - override def jvm: ProjectFinder = new SuffixBaseProjectFinder(jvmIdSuffix) + override def jsPlatform(scalaVersions: Seq[String]): ProjectMatrix = + jsPlatform(scalaVersions, Nil) + + override def jsPlatform(scalaVersions: Seq[String], settings: Seq[Setting[_]]): ProjectMatrix = + custom(jsIdSuffix, jsDirectorySuffix, scalaVersions, { _.settings(settings) }) + override def js: ProjectFinder = new SuffixBaseProjectFinder(jsIdSuffix) + override def crossLibrary(scalaVersions: Seq[String], suffix: String, settings: Seq[Setting[_]]): ProjectMatrix = + custom(suffix.replaceAllLiterally(".", "_"), + "-" + suffix.toLowerCase, + scalaVersions, + { _.settings( + Seq(moduleName := name.value + "_" + suffix.toLowerCase) ++ settings + ) }) + + override def crossLib(suffix: String): ProjectFinder = + new SuffixBaseProjectFinder(suffix.replaceAllLiterally(".", "_")) + override def projectRefs: Seq[ProjectReference] = componentProjects map { case p => (p: ProjectReference) } diff --git a/src/sbt-test/projectMatrix/crosslib/build.sbt b/src/sbt-test/projectMatrix/crosslib/build.sbt new file mode 100644 index 000000000..0d7010f3e --- /dev/null +++ b/src/sbt-test/projectMatrix/crosslib/build.sbt @@ -0,0 +1,35 @@ +ThisBuild / organization := "com.example" +ThisBuild / version := "0.1.0-SNAPSHOT" +ThisBuild / publishMavenStyle := true + +ThisBuild / ivyPaths := { + val base = (ThisBuild / baseDirectory).value + IvyPaths(base, Some(base / "ivy-cache")) +} +publish / skip := true + +lazy val core = (projectMatrix in file("core")) + .settings( + name := "core", + ivyPaths := (ThisBuild / ivyPaths).value + ) + .crossLibrary( + scalaVersions = Seq("2.12.8", "2.11.12"), + suffix = "Config1.2", + settings = Seq( + libraryDependencies += "com.typesafe" % "config" % "1.2.1" + ) + ) + .crossLibrary( + scalaVersions = Seq("2.12.8"), + suffix = "Config1.3", + settings = Seq( + libraryDependencies += "com.typesafe" % "config" % "1.3.3" + ) + ) + +// to reference project ref +lazy val coreConfig1_3 = core.crossLib("Config1.3")("2.12.8") + .settings( + publishMavenStyle := true + ) diff --git a/src/sbt-test/projectMatrix/crosslib/project/plugins.sbt b/src/sbt-test/projectMatrix/crosslib/project/plugins.sbt new file mode 100644 index 000000000..4e80bbafc --- /dev/null +++ b/src/sbt-test/projectMatrix/crosslib/project/plugins.sbt @@ -0,0 +1,5 @@ +sys.props.get("plugin.version") match { + case Some(x) => addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % x) + case _ => sys.error("""|The system property 'plugin.version' is not defined. + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin) +} diff --git a/src/sbt-test/projectMatrix/crosslib/test b/src/sbt-test/projectMatrix/crosslib/test new file mode 100644 index 000000000..909bf9e3a --- /dev/null +++ b/src/sbt-test/projectMatrix/crosslib/test @@ -0,0 +1,5 @@ +> publishLocal + +$ exists ivy-cache/local/com.example/core_config1.2_2.11/0.1.0-SNAPSHOT/poms/core_config1.2_2.11.pom +$ exists ivy-cache/local/com.example/core_config1.2_2.12/0.1.0-SNAPSHOT/poms/core_config1.2_2.12.pom +$ exists ivy-cache/local/com.example/core_config1.3_2.12/0.1.0-SNAPSHOT/poms/core_config1.3_2.12.pom