mirror of https://github.com/sbt/sbt.git
Expose project axes
This commit is contained in:
parent
839ff7d0f2
commit
ef62a9efe6
|
|
@ -0,0 +1,17 @@
|
|||
.bloop
|
||||
.metals
|
||||
|
||||
target
|
||||
|
||||
project/.bloop
|
||||
project/target
|
||||
project/project/target
|
||||
|
||||
*.class
|
||||
|
||||
metals.sbt
|
||||
|
||||
src/sbt-test/projectMatrix/projectAxes/target
|
||||
src/sbt-test/projectMatrix/projectAxes/project/target
|
||||
|
||||
|
||||
|
|
@ -8,6 +8,8 @@ import Keys._
|
|||
import scala.util.Try
|
||||
import sbt.internal.inc.ReflectUtilities
|
||||
|
||||
import sbtprojectmatrix.ProjectMatrixKeys
|
||||
|
||||
/**
|
||||
* A project matrix is an implementation of a composite project
|
||||
* that represents cross building across some axis (such as platform)
|
||||
|
|
@ -261,6 +263,7 @@ object ProjectMatrix {
|
|||
inConfig(Compile)(makeSources(nonScalaDirSuffix, svDirSuffix)),
|
||||
inConfig(Test)(makeSources(nonScalaDirSuffix, svDirSuffix)),
|
||||
projectDependencies := projectDependenciesTask.value,
|
||||
ProjectMatrixKeys.projectAxes := axes
|
||||
)
|
||||
.settings(self.settings)
|
||||
.configure(transforms: _*)
|
||||
|
|
|
|||
|
|
@ -5,10 +5,16 @@ import internal._
|
|||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import scala.language.experimental.macros
|
||||
|
||||
trait ProjectMatrixKeys {
|
||||
val projectAxes = settingKey[Seq[VirtualAxis]]("Virtual axes for the project")
|
||||
}
|
||||
|
||||
object ProjectMatrixKeys extends ProjectMatrixKeys
|
||||
|
||||
object ProjectMatrixPlugin extends AutoPlugin {
|
||||
override val requires = sbt.plugins.CorePlugin
|
||||
override val trigger = allRequirements
|
||||
object autoImport {
|
||||
object autoImport extends ProjectMatrixKeys {
|
||||
def projectMatrix: ProjectMatrix = macro ProjectMatrix.projectMatrixMacroImpl
|
||||
|
||||
implicit def matrixClasspathDependency[T](
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
lazy val scala213 = "2.13.3"
|
||||
lazy val scala212 = "2.12.12"
|
||||
lazy val check = taskKey[Unit]("")
|
||||
lazy val platformTest = settingKey[String]("")
|
||||
lazy val configTest = settingKey[String]("")
|
||||
|
||||
|
||||
lazy val config12 = ConfigAxis("Config1_2", "config1.2")
|
||||
lazy val config13 = ConfigAxis("Config1_3", "config1.3")
|
||||
|
||||
lazy val root = (project in file("."))
|
||||
.aggregate((core.projectRefs ++ custom.projectRefs):_*)
|
||||
|
||||
lazy val core = (projectMatrix in file("core"))
|
||||
.settings(
|
||||
check := {
|
||||
assert(platformTest.value.endsWith("-platform"))
|
||||
},
|
||||
)
|
||||
.jvmPlatform(scalaVersions = Seq(scala213, scala212))
|
||||
.jsPlatform(scalaVersions = Seq(scala212))
|
||||
.settings(platformSettings)
|
||||
|
||||
lazy val custom =
|
||||
(projectMatrix in file("custom"))
|
||||
.customRow(
|
||||
scalaVersions = Seq(scala212),
|
||||
axisValues = Seq(config13, VirtualAxis.jvm),
|
||||
_.settings()
|
||||
)
|
||||
.settings(platformSettings)
|
||||
.settings(customSettings)
|
||||
.settings(
|
||||
check := {
|
||||
assert(platformTest.value.endsWith("-platform"))
|
||||
assert(configTest.value.startsWith("config for"))
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
lazy val platformSettings = Seq[Def.Setting[_]](
|
||||
platformTest := {
|
||||
if(projectAxes.value.contains(sbt.VirtualAxis.js)) "js-platform"
|
||||
else if(projectAxes.value.contains(sbt.VirtualAxis.jvm)) "jvm-platform"
|
||||
else throw new RuntimeException(s"Something must be wrong (built-in platforms test) - projectAxes value is ${projectAxes.value}")
|
||||
}
|
||||
)
|
||||
|
||||
lazy val customSettings = Seq[Def.Setting[_]](
|
||||
configTest := {
|
||||
if(projectAxes.value.contains(config12)) "config for 1.2"
|
||||
else if (projectAxes.value.contains(config13)) "config for 1.3"
|
||||
else throw new RuntimeException(s"Something must be wrong (custom axis test ) - projectAxes value is ${projectAxes.value}")
|
||||
}
|
||||
)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
import sbt._
|
||||
|
||||
case class ConfigAxis(idSuffix: String, directorySuffix: String) extends VirtualAxis.WeakAxis
|
||||
|
|
@ -0,0 +1 @@
|
|||
sbt.version=1.4.0-M1
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
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)
|
||||
}
|
||||
|
||||
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.27")
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
> compile
|
||||
> check
|
||||
Loading…
Reference in New Issue