mirror of https://github.com/sbt/sbt.git
Add % syntax for configuration scoping
This commit is contained in:
parent
376c8f4a78
commit
b9a18bab2a
|
|
@ -160,6 +160,14 @@ object ProjectMatrix {
|
|||
override def toString: String = s"ProjectRow($autoScalaLibrary, $axisValues)"
|
||||
}
|
||||
|
||||
final class ProjectMatrixReferenceSyntax(m: ProjectMatrixReference) {
|
||||
def %(conf: String): ProjectMatrix.MatrixClasspathDependency =
|
||||
ProjectMatrix.MatrixClasspathDependency(m, Some(conf))
|
||||
|
||||
def %(conf: Configuration): ProjectMatrix.MatrixClasspathDependency =
|
||||
ProjectMatrix.MatrixClasspathDependency(m, Some(conf.name))
|
||||
}
|
||||
|
||||
final case class MatrixClasspathDependency(
|
||||
matrix: ProjectMatrixReference,
|
||||
configuration: Option[String]
|
||||
|
|
|
|||
|
|
@ -11,9 +11,14 @@ object ProjectMatrixPlugin extends AutoPlugin {
|
|||
object autoImport {
|
||||
def projectMatrix: ProjectMatrix = macro ProjectMatrix.projectMatrixMacroImpl
|
||||
|
||||
implicit def matrixClasspathDependency[T](
|
||||
implicit def matrixClasspathDependency[T](
|
||||
m: T
|
||||
)(implicit ev: T => ProjectMatrixReference): ProjectMatrix.MatrixClasspathDependency =
|
||||
ProjectMatrix.MatrixClasspathDependency(m, None)
|
||||
)(implicit ev: T => ProjectMatrixReference): ProjectMatrix.MatrixClasspathDependency =
|
||||
ProjectMatrix.MatrixClasspathDependency(m, None)
|
||||
|
||||
implicit def matrixReferenceSyntax[T](
|
||||
m: T
|
||||
)(implicit ev: T => ProjectMatrixReference): ProjectMatrix.ProjectMatrixReferenceSyntax =
|
||||
new ProjectMatrix.ProjectMatrixReferenceSyntax(m)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
package a
|
||||
|
||||
object Main extends App {
|
||||
val core = Core
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
lazy val check = taskKey[Unit]("")
|
||||
|
||||
lazy val root = (project in file("."))
|
||||
.aggregate(core.projectRefs ++ app.projectRefs: _*)
|
||||
.settings(
|
||||
)
|
||||
|
||||
lazy val app = (projectMatrix in file("app"))
|
||||
.aggregate(core, intf)
|
||||
.dependsOn(core % Compile, intf % "compile->compile;test->test")
|
||||
.settings(
|
||||
name := "app"
|
||||
)
|
||||
.jvmPlatform(scalaVersions = Seq("2.12.8"))
|
||||
|
||||
lazy val core = (projectMatrix in file("core"))
|
||||
.settings(
|
||||
check := {
|
||||
assert(moduleName.value == "core", s"moduleName is ${moduleName.value}")
|
||||
},
|
||||
)
|
||||
.jvmPlatform(scalaVersions = Seq("2.12.8", "2.11.12"))
|
||||
|
||||
lazy val intf = (projectMatrix in file("intf"))
|
||||
.settings(
|
||||
check := {
|
||||
assert(moduleName.value == "intf", s"moduleName is ${moduleName.value}")
|
||||
},
|
||||
)
|
||||
.jvmPlatform(autoScalaLibrary = false)
|
||||
|
||||
lazy val core212 = core.jvm("2.12.8")
|
||||
|
|
@ -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,6 @@
|
|||
> compile
|
||||
|
||||
$ exists core/target/jvm-2.12/classes/a/Core.class
|
||||
$ exists core/target/jvm-2.11/classes/a/Core.class
|
||||
|
||||
> coreJVM2_12/check
|
||||
Loading…
Reference in New Issue