mirror of https://github.com/sbt/sbt.git
add crossLibrary
It's a thin layer around custom, but specifically created for cross library building. Ref #2
This commit is contained in:
parent
f87730fb1b
commit
b520cc5517
|
|
@ -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) }
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
)
|
||||
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -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
|
||||
Loading…
Reference in New Issue