mirror of https://github.com/sbt/sbt.git
Merge remote-tracking branch 'upstream/master' into fix-wrong-hook
This commit is contained in:
commit
c8317bfb01
|
|
@ -67,6 +67,10 @@ sealed trait ProjectMatrix extends CompositeProject {
|
|||
|
||||
def jvm: ProjectFinder
|
||||
|
||||
def jsPlatform(settings: Setting[_]*): ProjectMatrix
|
||||
|
||||
def js: ProjectFinder
|
||||
|
||||
def projectRefs: Seq[ProjectReference]
|
||||
}
|
||||
|
||||
|
|
@ -86,6 +90,8 @@ object ProjectMatrix {
|
|||
|
||||
val jvmIdSuffix: String = "JVM"
|
||||
val jvmDirectorySuffix: String = "-jvm"
|
||||
val jsIdSuffix: String = "JS"
|
||||
val jsDirectorySuffix: String = "-js"
|
||||
|
||||
/** A row in the project matrix, typically representing a platform.
|
||||
*/
|
||||
|
|
@ -199,19 +205,26 @@ object ProjectMatrix {
|
|||
override def jvmPlatform(settings: Setting[_]*): ProjectMatrix =
|
||||
custom(jvmIdSuffix, jvmDirectorySuffix, Nil, { _.settings(settings) })
|
||||
|
||||
override def jvm: ProjectFinder = new ProjectFinder {
|
||||
def get: Seq[Project] = projectMatrix.toSeq collect {
|
||||
case ((r, sv), v) if r.idSuffix == jvmIdSuffix => v
|
||||
}
|
||||
def apply(sv: String): Project =
|
||||
(projectMatrix.toSeq collect {
|
||||
case ((r, `sv`), v) if r.idSuffix == jvmIdSuffix => v
|
||||
}).headOption.getOrElse(sys.error(s"$sv was not found"))
|
||||
}
|
||||
override def jsPlatform(settings: Setting[_]*): ProjectMatrix =
|
||||
custom(jsIdSuffix, jsDirectorySuffix, Nil, { _.settings(settings) })
|
||||
|
||||
override def jvm: ProjectFinder = new SuffixBaseProjectFinder(jvmIdSuffix)
|
||||
|
||||
override def js: ProjectFinder = new SuffixBaseProjectFinder(jsIdSuffix)
|
||||
|
||||
override def projectRefs: Seq[ProjectReference] =
|
||||
componentProjects map { case p => (p: ProjectReference) }
|
||||
|
||||
private final class SuffixBaseProjectFinder(idSuffix: String) extends ProjectFinder {
|
||||
def get: Seq[Project] = projectMatrix.toSeq collect {
|
||||
case ((r, sv), v) if r.idSuffix == idSuffix => v
|
||||
}
|
||||
def apply(sv: String): Project =
|
||||
(projectMatrix.toSeq collectFirst {
|
||||
case ((r, `sv`), v) if r.idSuffix == idSuffix => v
|
||||
}).getOrElse(sys.error(s"$sv was not found"))
|
||||
}
|
||||
|
||||
override def custom(
|
||||
idSuffix: String,
|
||||
directorySuffix: String,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
// lazy val root = (project in file("."))
|
||||
// .aggregate(core.projectRefs ++ app.projectRefs: _*)
|
||||
// .settings(
|
||||
// )
|
||||
|
||||
lazy val core = (projectMatrix in file("core"))
|
||||
.scalaVersions("2.12.6", "2.11.12")
|
||||
.settings(
|
||||
name := "core"
|
||||
)
|
||||
.jsPlatform()
|
||||
|
||||
lazy val app = (projectMatrix in file("app"))
|
||||
.dependsOn(core)
|
||||
.scalaVersions("2.12.6")
|
||||
.settings(
|
||||
name := "app"
|
||||
)
|
||||
.jsPlatform()
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package a
|
||||
|
||||
class Core {
|
||||
}
|
||||
|
||||
object Core extends Core
|
||||
|
|
@ -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,4 @@
|
|||
> compile
|
||||
|
||||
$ exists core/target/js-2.12/classes/a/Core.class
|
||||
$ exists core/target/js-2.11/classes/a/Core.class
|
||||
Loading…
Reference in New Issue