mirror of https://github.com/sbt/sbt.git
Merge sbt-projectmatrix
This commit is contained in:
parent
7c01636efa
commit
b59856bcba
|
|
@ -146,7 +146,7 @@ jobs:
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
# ./sbt -v "dependencyTreeProj/publishLocal; scripted dependency-graph/*"
|
# ./sbt -v "dependencyTreeProj/publishLocal; scripted dependency-graph/*"
|
||||||
./sbt -v --client "scripted dependency-management/* project-load/* java/* run/*"
|
./sbt -v --client "scripted dependency-management/* project-load/* project-matrix/* java/* run/*"
|
||||||
# ./sbt -v --client "scripted plugins/*"
|
# ./sbt -v --client "scripted plugins/*"
|
||||||
# ./sbt -v --client "scripted nio/*"
|
# ./sbt -v --client "scripted nio/*"
|
||||||
- name: Build and test (4)
|
- name: Build and test (4)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import scala.util.Try
|
||||||
// ThisBuild settings take lower precedence,
|
// ThisBuild settings take lower precedence,
|
||||||
// but can be shared across the multi projects.
|
// but can be shared across the multi projects.
|
||||||
ThisBuild / version := {
|
ThisBuild / version := {
|
||||||
val v = "2.0.0-alpha11-SNAPSHOT"
|
val v = "2.0.0-alpha12-SNAPSHOT"
|
||||||
nightlyVersion.getOrElse(v)
|
nightlyVersion.getOrElse(v)
|
||||||
}
|
}
|
||||||
ThisBuild / version2_13 := "2.0.0-alpha10-SNAPSHOT"
|
ThisBuild / version2_13 := "2.0.0-alpha10-SNAPSHOT"
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ private[sbt] object KeyMacro:
|
||||||
private def errorMsg2: String =
|
private def errorMsg2: String =
|
||||||
"""project must be directly assigned to a val, such as `val x = project.in(file("core"))`."""
|
"""project must be directly assigned to a val, such as `val x = project.in(file("core"))`."""
|
||||||
|
|
||||||
private def definingValName(errorMsg: String)(using qctx: Quotes): Expr[String] =
|
private[sbt] def definingValName(errorMsg: String)(using qctx: Quotes): Expr[String] =
|
||||||
val term = enclosingTerm
|
val term = enclosingTerm
|
||||||
if term.isValDef then Expr(term.name)
|
if term.isValDef then Expr(term.name)
|
||||||
else errorAndAbort(errorMsg)
|
else errorAndAbort(errorMsg)
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ private[sbt] trait BuildSyntax:
|
||||||
* Creates a new Project. This is a macro that expects to be assigned directly to a val.
|
* Creates a new Project. This is a macro that expects to be assigned directly to a val.
|
||||||
* The name of the val is used as the project ID and the name of the base directory of the project.
|
* The name of the val is used as the project ID and the name of the base directory of the project.
|
||||||
*/
|
*/
|
||||||
inline def project: Project =
|
inline def project: Project = ${ std.KeyMacro.projectImpl }
|
||||||
${ std.KeyMacro.projectImpl }
|
inline def projectMatrix: ProjectMatrix = ${ ProjectMatrix.projectMatrixImpl }
|
||||||
inline def settingKey[A1](inline description: String): SettingKey[A1] =
|
inline def settingKey[A1](inline description: String): SettingKey[A1] =
|
||||||
${ std.KeyMacro.settingKeyImpl[A1]('description) }
|
${ std.KeyMacro.settingKeyImpl[A1]('description) }
|
||||||
inline def taskKey[A1](inline description: String): TaskKey[A1] =
|
inline def taskKey[A1](inline description: String): TaskKey[A1] =
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,10 @@ object Keys {
|
||||||
|
|
||||||
val onComplete = Def.onComplete // settingKey[() => Unit]("Hook to run when task evaluation completes. The type of this setting is subject to change, pending the resolution of SI-2915.").withRank(DSetting)
|
val onComplete = Def.onComplete // settingKey[() => Unit]("Hook to run when task evaluation completes. The type of this setting is subject to change, pending the resolution of SI-2915.").withRank(DSetting)
|
||||||
|
|
||||||
|
// Project Matrix
|
||||||
|
val virtualAxes = settingKey[Seq[VirtualAxis]]("Virtual axes for the project")
|
||||||
|
val projectMatrixBaseDirectory = settingKey[File]("Base directory of the current project matrix")
|
||||||
|
|
||||||
// Command keys
|
// Command keys
|
||||||
val historyPath = SettingKey(BasicKeys.historyPath)
|
val historyPath = SettingKey(BasicKeys.historyPath)
|
||||||
val shellPrompt = SettingKey(BasicKeys.shellPrompt)
|
val shellPrompt = SettingKey(BasicKeys.shellPrompt)
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,20 @@
|
||||||
package sbt
|
package sbt
|
||||||
package internal
|
|
||||||
|
|
||||||
import java.util.Locale
|
import sbt.*
|
||||||
|
import sbt.Keys.*
|
||||||
|
import sbt.io.IO
|
||||||
|
import sbt.librarymanagement.Configuration
|
||||||
|
import sbt.librarymanagement.Configurations.*
|
||||||
|
import sbt.librarymanagement.CrossVersion
|
||||||
|
import sbt.librarymanagement.ModuleID
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
import java.lang.reflect.InvocationTargetException
|
||||||
import scala.collection.immutable.ListMap
|
import scala.collection.immutable.ListMap
|
||||||
import scala.collection.mutable
|
import scala.collection.mutable
|
||||||
import Keys._
|
import scala.quoted.*
|
||||||
|
import scala.reflect.ClassTag
|
||||||
import scala.util.Try
|
import scala.util.Try
|
||||||
import sbt.internal.inc.ReflectUtilities
|
|
||||||
|
|
||||||
import sbtprojectmatrix.ProjectMatrixKeys
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A project matrix is an implementation of a composite project
|
* A project matrix is an implementation of a composite project
|
||||||
|
|
@ -26,13 +32,13 @@ import sbtprojectmatrix.ProjectMatrixKeys
|
||||||
sealed trait ProjectMatrix extends CompositeProject {
|
sealed trait ProjectMatrix extends CompositeProject {
|
||||||
def id: String
|
def id: String
|
||||||
|
|
||||||
/** The base directory for the project matrix.*/
|
/** The base directory for the project matrix. */
|
||||||
def base: sbt.File
|
def base: File
|
||||||
|
|
||||||
def withId(id: String): ProjectMatrix
|
def withId(id: String): ProjectMatrix
|
||||||
|
|
||||||
/** Sets the base directory for this project matrix.*/
|
/** Sets the base directory for this project matrix. */
|
||||||
def in(dir: sbt.File): ProjectMatrix
|
def in(dir: File): ProjectMatrix
|
||||||
|
|
||||||
/** Adds new configurations directly to this project. To override an existing configuration, use `overrideConfigs`. */
|
/** Adds new configurations directly to this project. To override an existing configuration, use `overrideConfigs`. */
|
||||||
def configs(cs: Configuration*): ProjectMatrix
|
def configs(cs: Configuration*): ProjectMatrix
|
||||||
|
|
@ -41,7 +47,9 @@ sealed trait ProjectMatrix extends CompositeProject {
|
||||||
def dependsOn(deps: MatrixClasspathDep[ProjectMatrixReference]*): ProjectMatrix
|
def dependsOn(deps: MatrixClasspathDep[ProjectMatrixReference]*): ProjectMatrix
|
||||||
|
|
||||||
/** Adds classpath dependencies on internal or external non-matrix projects. */
|
/** Adds classpath dependencies on internal or external non-matrix projects. */
|
||||||
def dependsOn(deps: ClasspathDep[ProjectReference]*)(implicit dummyImplicit: DummyImplicit): ProjectMatrix
|
def dependsOn(deps: ClasspathDep[ProjectReference]*)(implicit
|
||||||
|
dummyImplicit: DummyImplicit
|
||||||
|
): ProjectMatrix
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds projects to be aggregated. When a user requests a task to run on this project from the command line,
|
* Adds projects to be aggregated. When a user requests a task to run on this project from the command line,
|
||||||
|
|
@ -78,54 +86,82 @@ sealed trait ProjectMatrix extends CompositeProject {
|
||||||
* Otherwise, add custom rows for each scalaVersions.
|
* Otherwise, add custom rows for each scalaVersions.
|
||||||
*/
|
*/
|
||||||
def customRow(
|
def customRow(
|
||||||
autoScalaLibrary: Boolean,
|
autoScalaLibrary: Boolean,
|
||||||
scalaVersions: Seq[String],
|
scalaVersions: Seq[String],
|
||||||
axisValues: Seq[VirtualAxis],
|
axisValues: Seq[VirtualAxis],
|
||||||
process: Project => Project
|
process: Project => Project
|
||||||
): ProjectMatrix
|
): ProjectMatrix
|
||||||
|
|
||||||
def customRow(
|
def customRow(
|
||||||
scalaVersions: Seq[String],
|
scalaVersions: Seq[String],
|
||||||
axisValues: Seq[VirtualAxis],
|
axisValues: Seq[VirtualAxis],
|
||||||
process: Project => Project
|
process: Project => Project
|
||||||
): ProjectMatrix
|
): ProjectMatrix
|
||||||
|
|
||||||
def customRow(
|
def customRow(
|
||||||
autoScalaLibrary: Boolean,
|
autoScalaLibrary: Boolean,
|
||||||
axisValues: Seq[VirtualAxis],
|
axisValues: Seq[VirtualAxis],
|
||||||
process: Project => Project
|
process: Project => Project
|
||||||
): ProjectMatrix
|
): ProjectMatrix
|
||||||
|
|
||||||
def customRow(
|
def customRow(
|
||||||
scalaVersions: Seq[String],
|
scalaVersions: Seq[String],
|
||||||
axisValues: Seq[VirtualAxis],
|
axisValues: Seq[VirtualAxis],
|
||||||
settings: Seq[Setting[_]]
|
settings: Seq[Def.Setting[_]]
|
||||||
): ProjectMatrix
|
): ProjectMatrix
|
||||||
|
|
||||||
def customRow(
|
def customRow(
|
||||||
autoScalaLibrary: Boolean,
|
autoScalaLibrary: Boolean,
|
||||||
axisValues: Seq[VirtualAxis],
|
axisValues: Seq[VirtualAxis],
|
||||||
settings: Seq[Setting[_]]
|
settings: Seq[Def.Setting[_]]
|
||||||
): ProjectMatrix
|
): ProjectMatrix
|
||||||
|
|
||||||
def jvmPlatform(scalaVersions: Seq[String]): ProjectMatrix
|
def jvmPlatform(scalaVersions: Seq[String]): ProjectMatrix
|
||||||
def jvmPlatform(autoScalaLibrary: Boolean): ProjectMatrix
|
def jvmPlatform(autoScalaLibrary: Boolean): ProjectMatrix
|
||||||
def jvmPlatform(scalaVersions: Seq[String], settings: Seq[Setting[_]]): ProjectMatrix
|
def jvmPlatform(scalaVersions: Seq[String], settings: Seq[Def.Setting[_]]): ProjectMatrix
|
||||||
def jvmPlatform(scalaVersions: Seq[String], axisValues: Seq[VirtualAxis], settings: Seq[Setting[_]]): ProjectMatrix
|
def jvmPlatform(
|
||||||
def jvmPlatform(scalaVersions: Seq[String], axisValues: Seq[VirtualAxis], configure: Project => Project): ProjectMatrix
|
scalaVersions: Seq[String],
|
||||||
def jvmPlatform(autoScalaLibrary: Boolean, scalaVersions: Seq[String], settings: Seq[Setting[_]]): ProjectMatrix
|
axisValues: Seq[VirtualAxis],
|
||||||
|
settings: Seq[Def.Setting[_]]
|
||||||
|
): ProjectMatrix
|
||||||
|
def jvmPlatform(
|
||||||
|
scalaVersions: Seq[String],
|
||||||
|
axisValues: Seq[VirtualAxis],
|
||||||
|
configure: Project => Project
|
||||||
|
): ProjectMatrix
|
||||||
|
def jvmPlatform(
|
||||||
|
autoScalaLibrary: Boolean,
|
||||||
|
scalaVersions: Seq[String],
|
||||||
|
settings: Seq[Def.Setting[_]]
|
||||||
|
): ProjectMatrix
|
||||||
def jvm: ProjectFinder
|
def jvm: ProjectFinder
|
||||||
|
|
||||||
def jsPlatform(scalaVersions: Seq[String]): ProjectMatrix
|
def jsPlatform(scalaVersions: Seq[String]): ProjectMatrix
|
||||||
def jsPlatform(scalaVersions: Seq[String], settings: Seq[Setting[_]]): ProjectMatrix
|
def jsPlatform(scalaVersions: Seq[String], settings: Seq[Def.Setting[_]]): ProjectMatrix
|
||||||
def jsPlatform(scalaVersions: Seq[String], axisValues: Seq[VirtualAxis], settings: Seq[Setting[_]]): ProjectMatrix
|
def jsPlatform(
|
||||||
def jsPlatform(scalaVersions: Seq[String], axisValues: Seq[VirtualAxis], configure: Project => Project): ProjectMatrix
|
scalaVersions: Seq[String],
|
||||||
|
axisValues: Seq[VirtualAxis],
|
||||||
|
settings: Seq[Def.Setting[_]]
|
||||||
|
): ProjectMatrix
|
||||||
|
def jsPlatform(
|
||||||
|
scalaVersions: Seq[String],
|
||||||
|
axisValues: Seq[VirtualAxis],
|
||||||
|
configure: Project => Project
|
||||||
|
): ProjectMatrix
|
||||||
def js: ProjectFinder
|
def js: ProjectFinder
|
||||||
|
|
||||||
def nativePlatform(scalaVersions: Seq[String]): ProjectMatrix
|
def nativePlatform(scalaVersions: Seq[String]): ProjectMatrix
|
||||||
def nativePlatform(scalaVersions: Seq[String], settings: Seq[Setting[_]]): ProjectMatrix
|
def nativePlatform(scalaVersions: Seq[String], settings: Seq[Def.Setting[_]]): ProjectMatrix
|
||||||
def nativePlatform(scalaVersions: Seq[String], axisValues: Seq[VirtualAxis], settings: Seq[Setting[_]]): ProjectMatrix
|
def nativePlatform(
|
||||||
def nativePlatform(scalaVersions: Seq[String], axisValues: Seq[VirtualAxis], configure: Project => Project): ProjectMatrix
|
scalaVersions: Seq[String],
|
||||||
|
axisValues: Seq[VirtualAxis],
|
||||||
|
settings: Seq[Def.Setting[_]]
|
||||||
|
): ProjectMatrix
|
||||||
|
def nativePlatform(
|
||||||
|
scalaVersions: Seq[String],
|
||||||
|
axisValues: Seq[VirtualAxis],
|
||||||
|
configure: Project => Project
|
||||||
|
): ProjectMatrix
|
||||||
def native: ProjectFinder
|
def native: ProjectFinder
|
||||||
|
|
||||||
def defaultAxes(axes: VirtualAxis*): ProjectMatrix
|
def defaultAxes(axes: VirtualAxis*): ProjectMatrix
|
||||||
|
|
@ -141,7 +177,8 @@ sealed trait ProjectMatrix extends CompositeProject {
|
||||||
private[sbt] def resolveMatch(thatRow: ProjectMatrix.ProjectRow): ProjectReference
|
private[sbt] def resolveMatch(thatRow: ProjectMatrix.ProjectRow): ProjectReference
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Represents a reference to a project matrix with an optional configuration string.
|
/**
|
||||||
|
* Represents a reference to a project matrix with an optional configuration string.
|
||||||
*/
|
*/
|
||||||
sealed trait MatrixClasspathDep[MR <: ProjectMatrixReference] {
|
sealed trait MatrixClasspathDep[MR <: ProjectMatrixReference] {
|
||||||
def matrix: MR; def configuration: Option[String]
|
def matrix: MR; def configuration: Option[String]
|
||||||
|
|
@ -165,7 +202,8 @@ object ProjectMatrix {
|
||||||
|
|
||||||
private[sbt] val allMatrices: mutable.Map[String, ProjectMatrix] = mutable.Map.empty
|
private[sbt] val allMatrices: mutable.Map[String, ProjectMatrix] = mutable.Map.empty
|
||||||
|
|
||||||
/** A row in the project matrix, typically representing a platform + Scala version.
|
/**
|
||||||
|
* A row in the project matrix, typically representing a platform + Scala version.
|
||||||
*/
|
*/
|
||||||
final class ProjectRow(
|
final class ProjectRow(
|
||||||
val autoScalaLibrary: Boolean,
|
val autoScalaLibrary: Boolean,
|
||||||
|
|
@ -174,8 +212,8 @@ object ProjectMatrix {
|
||||||
) {
|
) {
|
||||||
def scalaVersionOpt: Option[String] =
|
def scalaVersionOpt: Option[String] =
|
||||||
if (autoScalaLibrary)
|
if (autoScalaLibrary)
|
||||||
(axisValues collect {
|
(axisValues collect { case sv: VirtualAxis.ScalaVersionAxis =>
|
||||||
case sv: VirtualAxis.ScalaVersionAxis => sv.scalaVersion
|
sv.scalaVersion
|
||||||
}).headOption
|
}).headOption
|
||||||
else None
|
else None
|
||||||
|
|
||||||
|
|
@ -203,7 +241,7 @@ object ProjectMatrix {
|
||||||
|
|
||||||
private final class ProjectMatrixDef(
|
private final class ProjectMatrixDef(
|
||||||
val id: String,
|
val id: String,
|
||||||
val base: sbt.File,
|
val base: File,
|
||||||
val scalaVersions: Seq[String],
|
val scalaVersions: Seq[String],
|
||||||
val rows: Seq[ProjectRow],
|
val rows: Seq[ProjectRow],
|
||||||
val aggregate: Seq[ProjectMatrixReference],
|
val aggregate: Seq[ProjectMatrixReference],
|
||||||
|
|
@ -221,7 +259,8 @@ object ProjectMatrix {
|
||||||
Map((for {
|
Map((for {
|
||||||
r <- rows
|
r <- rows
|
||||||
} yield {
|
} yield {
|
||||||
val axes = r.axisValues.sortBy(_.suffixOrder)
|
val axes = r.axisValues
|
||||||
|
.sortBy(_.suffixOrder)
|
||||||
.filterNot(isSortOfDefaultAxis)
|
.filterNot(isSortOfDefaultAxis)
|
||||||
val idSuffix = axes.map(_.idSuffix).mkString("")
|
val idSuffix = axes.map(_.idSuffix).mkString("")
|
||||||
val childId = self.id + idSuffix
|
val childId = self.id + idSuffix
|
||||||
|
|
@ -234,105 +273,110 @@ object ProjectMatrix {
|
||||||
|
|
||||||
private def resolveMappings: ListMap[ProjectRow, Project] = {
|
private def resolveMappings: ListMap[ProjectRow, Project] = {
|
||||||
val projectIds = resolveProjectIds
|
val projectIds = resolveProjectIds
|
||||||
|
def dirSuffix(axes: Seq[VirtualAxis]): String =
|
||||||
ListMap((for {
|
axes.map(_.directorySuffix).filter(_.nonEmpty).mkString("-")
|
||||||
r <- rows
|
val projects =
|
||||||
} yield {
|
rows.map { r =>
|
||||||
val axes = r.axisValues.sortBy(_.suffixOrder)
|
import VirtualAxis.*
|
||||||
val svDirSuffix = axes.map(_.directorySuffix).mkString("-")
|
val axes = r.axisValues.sortBy(_.suffixOrder)
|
||||||
val nonScalaDirSuffix = (axes filter {
|
val scalaDirSuffix = dirSuffix(axes)
|
||||||
case _: VirtualAxis.ScalaVersionAxis => false
|
val nonScalaDirSuffix = dirSuffix(axes.filterNot(_.isInstanceOf[ScalaVersionAxis]))
|
||||||
case _ => true
|
val nonScalaNorPlatformDirSuffix =
|
||||||
}).map(_.directorySuffix).mkString("-")
|
dirSuffix(axes.filterNot(_.isInstanceOf[ScalaVersionAxis | PlatformAxis]))
|
||||||
|
val platform = axes
|
||||||
val platform = (axes collect {
|
.collect { case pa: VirtualAxis.PlatformAxis =>
|
||||||
case pa: VirtualAxis.PlatformAxis => pa
|
pa
|
||||||
}).headOption.getOrElse(sys.error(s"platform axis is missing in $axes"))
|
}
|
||||||
val childId = projectIds(r)
|
.headOption
|
||||||
val deps = dependencies.map { resolveMatrixDependency(_, r) } ++ nonMatrixDependencies
|
.getOrElse(sys.error(s"platform axis is missing in $axes"))
|
||||||
val aggs = aggregate.map {
|
val childId = projectIds(r)
|
||||||
case ref: LocalProjectMatrix =>
|
val deps = dependencies.map { resolveMatrixDependency(_, r) } ++ nonMatrixDependencies
|
||||||
|
val aggs = aggregate.map { case ref: LocalProjectMatrix =>
|
||||||
val other = lookupMatrix(ref)
|
val other = lookupMatrix(ref)
|
||||||
resolveMatrixAggregate(other, r)
|
resolveMatrixAggregate(other, r)
|
||||||
} ++ nonMatrixAggregate
|
} ++ nonMatrixAggregate
|
||||||
val dotSbtMatrix = new java.io.File(".sbt") / "matrix"
|
val dotSbtMatrix = new java.io.File(".sbt") / "matrix"
|
||||||
IO.createDirectory(dotSbtMatrix)
|
IO.createDirectory(dotSbtMatrix)
|
||||||
val p = Project(childId, dotSbtMatrix / childId)
|
val p = Project(childId, dotSbtMatrix / childId)
|
||||||
.dependsOn(deps: _*)
|
.dependsOn(deps: _*)
|
||||||
.aggregate(aggs: _*)
|
.aggregate(aggs: _*)
|
||||||
.setPlugins(plugins)
|
.setPlugins(plugins)
|
||||||
.configs(configurations: _*)
|
.configs(configurations: _*)
|
||||||
.settings(
|
.settings(
|
||||||
name := self.id
|
name := self.id
|
||||||
)
|
)
|
||||||
.settings(
|
.settings(
|
||||||
r.scalaVersionOpt match {
|
r.scalaVersionOpt match {
|
||||||
case Some(sv) =>
|
case Some(sv) =>
|
||||||
List(Keys.scalaVersion := sv)
|
List(scalaVersion := sv)
|
||||||
case _ =>
|
case _ =>
|
||||||
List(Keys.autoScalaLibrary := false, Keys.crossPaths := false)
|
List(autoScalaLibrary := false, crossPaths := false)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.settings(
|
.settings(
|
||||||
target := base.getAbsoluteFile / "target" / svDirSuffix.dropWhile(_ == '-'),
|
outputPath := {
|
||||||
crossTarget := Keys.target.value,
|
val o = outputPath.value
|
||||||
sourceDirectory := base.getAbsoluteFile / "src",
|
if nonScalaNorPlatformDirSuffix.nonEmpty then s"$o/$nonScalaNorPlatformDirSuffix"
|
||||||
unmanagedBase := base.getAbsoluteFile / "lib",
|
else o
|
||||||
inConfig(Compile)(makeSources(nonScalaDirSuffix, svDirSuffix)),
|
},
|
||||||
inConfig(Test)(makeSources(nonScalaDirSuffix, svDirSuffix)),
|
sourceDirectory := base.getAbsoluteFile / "src",
|
||||||
projectDependencies := projectDependenciesTask.value,
|
unmanagedBase := base.getAbsoluteFile / "lib",
|
||||||
ProjectMatrixKeys.virtualAxes := axes,
|
ProjectExtra.inConfig(Compile)(makeSources(nonScalaDirSuffix, scalaDirSuffix)),
|
||||||
ProjectMatrixKeys.projectMatrixBaseDirectory := base,
|
ProjectExtra.inConfig(Test)(makeSources(nonScalaDirSuffix, scalaDirSuffix)),
|
||||||
)
|
projectDependencies := projectDependenciesTask.value,
|
||||||
.settings(self.settings)
|
virtualAxes := axes,
|
||||||
.configure(transforms: _*)
|
projectMatrixBaseDirectory := base,
|
||||||
|
)
|
||||||
|
.settings(self.settings)
|
||||||
|
.configure(transforms: _*)
|
||||||
|
|
||||||
r -> r.process(p)
|
r -> r.process(p)
|
||||||
}): _*)
|
}
|
||||||
|
ListMap(projects*)
|
||||||
}
|
}
|
||||||
|
|
||||||
// backport of https://github.com/sbt/sbt/pull/5767
|
// backport of https://github.com/sbt/sbt/pull/5767
|
||||||
def projectDependenciesTask: Def.Initialize[Task[Seq[ModuleID]]] =
|
def projectDependenciesTask: Def.Initialize[Task[Seq[ModuleID]]] =
|
||||||
Def.task {
|
Def.task {
|
||||||
val orig = projectDependencies.value
|
val orig = projectDependencies.value
|
||||||
val sbv = scalaBinaryVersion.value
|
val sbv = scalaBinaryVersion.value
|
||||||
val ref = thisProjectRef.value
|
val ref = thisProjectRef.value
|
||||||
val data = settingsData.value
|
val data = settingsData.value
|
||||||
val deps = buildDependencies.value
|
val deps = buildDependencies.value
|
||||||
deps.classpath(ref) flatMap { dep =>
|
deps.classpath(ref) flatMap { dep =>
|
||||||
for {
|
for {
|
||||||
depProjId <- (dep.project / projectID).get(data)
|
depProjId <- (dep.project / projectID).get(data)
|
||||||
depSBV <- (dep.project / scalaBinaryVersion).get(data)
|
depSBV <- (dep.project / scalaBinaryVersion).get(data)
|
||||||
depCross <- (dep.project / crossVersion).get(data)
|
depCross <- (dep.project / crossVersion).get(data)
|
||||||
} yield {
|
} yield {
|
||||||
depCross match {
|
depCross match {
|
||||||
case b: CrossVersion.Binary if VirtualAxis.isScala2Scala3Sandwich(sbv, depSBV) =>
|
case b: CrossVersion.Binary if VirtualAxis.isScala2Scala3Sandwich(sbv, depSBV) =>
|
||||||
depProjId
|
depProjId
|
||||||
.withCrossVersion(CrossVersion.constant(depSBV))
|
.withCrossVersion(CrossVersion.constant(depSBV))
|
||||||
.withConfigurations(dep.configuration)
|
.withConfigurations(dep.configuration)
|
||||||
.withExplicitArtifacts(Vector.empty)
|
.withExplicitArtifacts(Vector.empty)
|
||||||
case _ =>
|
case _ =>
|
||||||
depProjId.withConfigurations(dep.configuration).withExplicitArtifacts(Vector.empty)
|
depProjId.withConfigurations(dep.configuration).withExplicitArtifacts(Vector.empty)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override lazy val componentProjects: Seq[Project] = resolvedMappings.values.toList
|
override lazy val componentProjects: Seq[Project] = resolvedMappings.values.toList
|
||||||
|
|
||||||
private def resolveMatrixAggregate(
|
private def resolveMatrixAggregate(
|
||||||
other: ProjectMatrix,
|
other: ProjectMatrix,
|
||||||
thisRow: ProjectRow,
|
thisRow: ProjectRow,
|
||||||
): ProjectReference = other.resolveMatch(thisRow)
|
): ProjectReference = other.resolveMatch(thisRow)
|
||||||
|
|
||||||
private def resolveMatrixDependency(
|
private def resolveMatrixDependency(
|
||||||
dep: MatrixClasspathDep[ProjectMatrixReference],
|
dep: MatrixClasspathDep[ProjectMatrixReference],
|
||||||
thisRow: ProjectRow
|
thisRow: ProjectRow
|
||||||
): ClasspathDep[ProjectReference] =
|
): ClasspathDep[ProjectReference] =
|
||||||
dep match {
|
dep match {
|
||||||
case MatrixClasspathDependency(matrix0: LocalProjectMatrix, configuration) =>
|
case MatrixClasspathDependency(matrix0: LocalProjectMatrix, configuration) =>
|
||||||
val other = lookupMatrix(matrix0)
|
val other = lookupMatrix(matrix0)
|
||||||
ClasspathDependency(other.resolveMatch(thisRow), configuration)
|
ClasspathDep.ClasspathDependency(other.resolveMatch(thisRow), configuration)
|
||||||
}
|
}
|
||||||
|
|
||||||
// resolve to the closest match for the given row
|
// resolve to the closest match for the given row
|
||||||
|
|
@ -343,7 +387,7 @@ object ProjectMatrix {
|
||||||
case _ => sys.error(s"no rows were found in $id matching $thatRow: $rows")
|
case _ => sys.error(s"no rows were found in $id matching $thatRow: $rows")
|
||||||
}
|
}
|
||||||
|
|
||||||
private def makeSources(dirSuffix: String, svDirSuffix: String): Setting[_] = {
|
private def makeSources(dirSuffix: String, svDirSuffix: String): Def.Setting[_] = {
|
||||||
unmanagedSourceDirectories ++= Seq(
|
unmanagedSourceDirectories ++= Seq(
|
||||||
scalaSource.value.getParentFile / s"scala${dirSuffix}",
|
scalaSource.value.getParentFile / s"scala${dirSuffix}",
|
||||||
scalaSource.value.getParentFile / s"scala$svDirSuffix",
|
scalaSource.value.getParentFile / s"scala$svDirSuffix",
|
||||||
|
|
@ -353,7 +397,7 @@ object ProjectMatrix {
|
||||||
|
|
||||||
override def withId(id: String): ProjectMatrix = copy(id = id)
|
override def withId(id: String): ProjectMatrix = copy(id = id)
|
||||||
|
|
||||||
override def in(dir: sbt.File): ProjectMatrix = copy(base = dir)
|
override def in(dir: File): ProjectMatrix = copy(base = dir)
|
||||||
|
|
||||||
override def configs(cs: Configuration*): ProjectMatrix =
|
override def configs(cs: Configuration*): ProjectMatrix =
|
||||||
copy(configurations = configurations ++ cs)
|
copy(configurations = configurations ++ cs)
|
||||||
|
|
@ -361,13 +405,17 @@ object ProjectMatrix {
|
||||||
override def aggregate(refs: ProjectMatrixReference*): ProjectMatrix =
|
override def aggregate(refs: ProjectMatrixReference*): ProjectMatrix =
|
||||||
copy(aggregate = (aggregate: Seq[ProjectMatrixReference]) ++ refs)
|
copy(aggregate = (aggregate: Seq[ProjectMatrixReference]) ++ refs)
|
||||||
|
|
||||||
override def aggregate(refs: ProjectReference*)(implicit dummyImplicit: DummyImplicit): ProjectMatrix =
|
override def aggregate(refs: ProjectReference*)(implicit
|
||||||
|
dummyImplicit: DummyImplicit
|
||||||
|
): ProjectMatrix =
|
||||||
copy(nonMatrixAggregate = (nonMatrixAggregate: Seq[ProjectReference]) ++ refs)
|
copy(nonMatrixAggregate = (nonMatrixAggregate: Seq[ProjectReference]) ++ refs)
|
||||||
|
|
||||||
override def dependsOn(deps: MatrixClasspathDep[ProjectMatrixReference]*): ProjectMatrix =
|
override def dependsOn(deps: MatrixClasspathDep[ProjectMatrixReference]*): ProjectMatrix =
|
||||||
copy(dependencies = dependencies ++ deps)
|
copy(dependencies = dependencies ++ deps)
|
||||||
|
|
||||||
override def dependsOn(deps: ClasspathDep[ProjectReference]*)(implicit dummyImplicit: DummyImplicit) =
|
override def dependsOn(deps: ClasspathDep[ProjectReference]*)(implicit
|
||||||
|
dummyImplicit: DummyImplicit
|
||||||
|
) =
|
||||||
copy(nonMatrixDependencies = nonMatrixDependencies ++ deps)
|
copy(nonMatrixDependencies = nonMatrixDependencies ++ deps)
|
||||||
|
|
||||||
/** Appends settings to the current settings sequence for this project. */
|
/** Appends settings to the current settings sequence for this project. */
|
||||||
|
|
@ -389,15 +437,30 @@ object ProjectMatrix {
|
||||||
jvmPlatform(scalaVersions, Nil)
|
jvmPlatform(scalaVersions, Nil)
|
||||||
override def jvmPlatform(autoScalaLibrary: Boolean): ProjectMatrix =
|
override def jvmPlatform(autoScalaLibrary: Boolean): ProjectMatrix =
|
||||||
jvmPlatform(autoScalaLibrary, Nil, Nil)
|
jvmPlatform(autoScalaLibrary, Nil, Nil)
|
||||||
override def jvmPlatform(scalaVersions: Seq[String], settings: Seq[Setting[_]]): ProjectMatrix =
|
override def jvmPlatform(
|
||||||
|
scalaVersions: Seq[String],
|
||||||
|
settings: Seq[Def.Setting[_]]
|
||||||
|
): ProjectMatrix =
|
||||||
jvmPlatform(true, scalaVersions, settings)
|
jvmPlatform(true, scalaVersions, settings)
|
||||||
override def jvmPlatform(autoScalaLibrary: Boolean, scalaVersions: Seq[String], settings: Seq[Setting[_]]): ProjectMatrix =
|
override def jvmPlatform(
|
||||||
|
autoScalaLibrary: Boolean,
|
||||||
|
scalaVersions: Seq[String],
|
||||||
|
settings: Seq[Def.Setting[_]]
|
||||||
|
): ProjectMatrix =
|
||||||
customRow(autoScalaLibrary, scalaVersions, Seq(VirtualAxis.jvm), { _.settings(settings) })
|
customRow(autoScalaLibrary, scalaVersions, Seq(VirtualAxis.jvm), { _.settings(settings) })
|
||||||
|
|
||||||
override def jvmPlatform(scalaVersions: Seq[String], axisValues: Seq[VirtualAxis], settings: Seq[Setting[_]]): ProjectMatrix =
|
override def jvmPlatform(
|
||||||
customRow(true, scalaVersions, VirtualAxis.jvm +: axisValues, {_.settings(settings)})
|
scalaVersions: Seq[String],
|
||||||
|
axisValues: Seq[VirtualAxis],
|
||||||
override def jvmPlatform(scalaVersions: Seq[String], axisValues: Seq[VirtualAxis], configure: Project => Project): ProjectMatrix =
|
settings: Seq[Def.Setting[_]]
|
||||||
|
): ProjectMatrix =
|
||||||
|
customRow(true, scalaVersions, VirtualAxis.jvm +: axisValues, { _.settings(settings) })
|
||||||
|
|
||||||
|
override def jvmPlatform(
|
||||||
|
scalaVersions: Seq[String],
|
||||||
|
axisValues: Seq[VirtualAxis],
|
||||||
|
configure: Project => Project
|
||||||
|
): ProjectMatrix =
|
||||||
customRow(true, scalaVersions, VirtualAxis.jvm +: axisValues, configure)
|
customRow(true, scalaVersions, VirtualAxis.jvm +: axisValues, configure)
|
||||||
|
|
||||||
override def jvm: ProjectFinder = new AxisBaseProjectFinder(Seq(VirtualAxis.jvm))
|
override def jvm: ProjectFinder = new AxisBaseProjectFinder(Seq(VirtualAxis.jvm))
|
||||||
|
|
@ -405,31 +468,57 @@ object ProjectMatrix {
|
||||||
override def jsPlatform(scalaVersions: Seq[String]): ProjectMatrix =
|
override def jsPlatform(scalaVersions: Seq[String]): ProjectMatrix =
|
||||||
jsPlatform(scalaVersions, Nil)
|
jsPlatform(scalaVersions, Nil)
|
||||||
|
|
||||||
private def enableScalaJSPlugin(project: Project): Project =
|
private def enableScalaJSPlugin(project: Project): Project =
|
||||||
project.enablePlugins(scalajsPlugin(this.getClass.getClassLoader).getOrElse(
|
project.enablePlugins(
|
||||||
sys.error("""Scala.js plugin was not found. Add the sbt-scalajs plugin into project/plugins.sbt:
|
scalajsPlugin(this.getClass.getClassLoader).getOrElse(
|
||||||
|
sys.error(
|
||||||
|
"""Scala.js plugin was not found. Add the sbt-scalajs plugin into project/plugins.sbt:
|
||||||
| addSbtPlugin("org.scala-js" % "sbt-scalajs" % "x.y.z")
|
| addSbtPlugin("org.scala-js" % "sbt-scalajs" % "x.y.z")
|
||||||
|""".stripMargin)
|
|""".stripMargin
|
||||||
))
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
override def jsPlatform(
|
||||||
|
scalaVersions: Seq[String],
|
||||||
|
settings: Seq[Def.Setting[_]]
|
||||||
|
): ProjectMatrix =
|
||||||
|
customRow(
|
||||||
|
true,
|
||||||
|
scalaVersions,
|
||||||
|
Seq(VirtualAxis.js),
|
||||||
|
project => enableScalaJSPlugin(project).settings(settings)
|
||||||
|
)
|
||||||
|
|
||||||
override def jsPlatform(scalaVersions: Seq[String], settings: Seq[Setting[_]]): ProjectMatrix =
|
override def jsPlatform(
|
||||||
customRow(true, scalaVersions, Seq(VirtualAxis.js),
|
scalaVersions: Seq[String],
|
||||||
project => enableScalaJSPlugin(project).settings(settings))
|
axisValues: Seq[VirtualAxis],
|
||||||
|
settings: Seq[Def.Setting[_]]
|
||||||
override def jsPlatform(scalaVersions: Seq[String], axisValues: Seq[VirtualAxis], settings: Seq[Setting[_]]): ProjectMatrix =
|
): ProjectMatrix =
|
||||||
customRow(true, scalaVersions, VirtualAxis.js +: axisValues,
|
customRow(
|
||||||
project => enableScalaJSPlugin(project).settings(settings))
|
true,
|
||||||
|
scalaVersions,
|
||||||
override def jsPlatform(scalaVersions: Seq[String], axisValues: Seq[VirtualAxis], configure: Project => Project): ProjectMatrix =
|
VirtualAxis.js +: axisValues,
|
||||||
customRow(true, scalaVersions, VirtualAxis.js +: axisValues,
|
project => enableScalaJSPlugin(project).settings(settings)
|
||||||
project => configure(enableScalaJSPlugin(project)))
|
)
|
||||||
|
|
||||||
|
override def jsPlatform(
|
||||||
|
scalaVersions: Seq[String],
|
||||||
|
axisValues: Seq[VirtualAxis],
|
||||||
|
configure: Project => Project
|
||||||
|
): ProjectMatrix =
|
||||||
|
customRow(
|
||||||
|
true,
|
||||||
|
scalaVersions,
|
||||||
|
VirtualAxis.js +: axisValues,
|
||||||
|
project => configure(enableScalaJSPlugin(project))
|
||||||
|
)
|
||||||
|
|
||||||
override def defaultAxes(axes: VirtualAxis*): ProjectMatrix =
|
override def defaultAxes(axes: VirtualAxis*): ProjectMatrix =
|
||||||
copy(defAxes = axes.toSeq)
|
copy(defAxes = axes.toSeq)
|
||||||
|
|
||||||
def scalajsPlugin(classLoader: ClassLoader): Try[AutoPlugin] = {
|
def scalajsPlugin(classLoader: ClassLoader): Try[AutoPlugin] = {
|
||||||
import sbtprojectmatrix.ReflectionUtil._
|
import ReflectionUtil.*
|
||||||
withContextClassloader(classLoader) { loader =>
|
withContextClassloader(classLoader) { loader =>
|
||||||
getSingletonObject[AutoPlugin](loader, "org.scalajs.sbtplugin.ScalaJSPlugin$")
|
getSingletonObject[AutoPlugin](loader, "org.scalajs.sbtplugin.ScalaJSPlugin$")
|
||||||
}
|
}
|
||||||
|
|
@ -442,88 +531,126 @@ object ProjectMatrix {
|
||||||
override def nativePlatform(scalaVersions: Seq[String]): ProjectMatrix =
|
override def nativePlatform(scalaVersions: Seq[String]): ProjectMatrix =
|
||||||
nativePlatform(scalaVersions, Nil)
|
nativePlatform(scalaVersions, Nil)
|
||||||
|
|
||||||
private def enableScalaNativePlugin(project: Project): Project =
|
private def enableScalaNativePlugin(project: Project): Project =
|
||||||
project.enablePlugins(nativePlugin(this.getClass.getClassLoader).getOrElse(
|
project.enablePlugins(
|
||||||
sys.error("""Scala Native plugin was not found. Add the sbt-scala-native plugin into project/plugins.sbt:
|
nativePlugin(this.getClass.getClassLoader).getOrElse(
|
||||||
|
sys.error(
|
||||||
|
"""Scala Native plugin was not found. Add the sbt-scala-native plugin into project/plugins.sbt:
|
||||||
| addSbtPlugin("org.scala-native" % "sbt-scala-native" % "x.y.z")
|
| addSbtPlugin("org.scala-native" % "sbt-scala-native" % "x.y.z")
|
||||||
|""".stripMargin)
|
|""".stripMargin
|
||||||
))
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
override def nativePlatform(
|
||||||
|
scalaVersions: Seq[String],
|
||||||
|
settings: Seq[Def.Setting[_]]
|
||||||
|
): ProjectMatrix =
|
||||||
|
customRow(
|
||||||
|
true,
|
||||||
|
scalaVersions,
|
||||||
|
Seq(VirtualAxis.native),
|
||||||
|
project => enableScalaNativePlugin(project).settings(settings)
|
||||||
|
)
|
||||||
|
|
||||||
override def nativePlatform(scalaVersions: Seq[String], settings: Seq[Setting[_]]): ProjectMatrix =
|
override def nativePlatform(
|
||||||
customRow(true, scalaVersions, Seq(VirtualAxis.native), project => enableScalaNativePlugin(project).settings(settings))
|
scalaVersions: Seq[String],
|
||||||
|
axisValues: Seq[VirtualAxis],
|
||||||
override def nativePlatform(scalaVersions: Seq[String], axisValues: Seq[VirtualAxis], settings: Seq[Setting[_]]): ProjectMatrix =
|
settings: Seq[Def.Setting[_]]
|
||||||
customRow(true, scalaVersions, VirtualAxis.native +: axisValues, project => enableScalaNativePlugin(project).settings(settings))
|
): ProjectMatrix =
|
||||||
|
customRow(
|
||||||
|
true,
|
||||||
|
scalaVersions,
|
||||||
|
VirtualAxis.native +: axisValues,
|
||||||
|
project => enableScalaNativePlugin(project).settings(settings)
|
||||||
|
)
|
||||||
|
|
||||||
override def nativePlatform(scalaVersions: Seq[String], axisValues: Seq[VirtualAxis], configure: Project => Project): ProjectMatrix =
|
override def nativePlatform(
|
||||||
customRow(true, scalaVersions, VirtualAxis.native +: axisValues, project => configure(enableScalaNativePlugin(project)))
|
scalaVersions: Seq[String],
|
||||||
|
axisValues: Seq[VirtualAxis],
|
||||||
|
configure: Project => Project
|
||||||
|
): ProjectMatrix =
|
||||||
|
customRow(
|
||||||
|
true,
|
||||||
|
scalaVersions,
|
||||||
|
VirtualAxis.native +: axisValues,
|
||||||
|
project => configure(enableScalaNativePlugin(project))
|
||||||
|
)
|
||||||
|
|
||||||
def nativePlugin(classLoader: ClassLoader): Try[AutoPlugin] = {
|
def nativePlugin(classLoader: ClassLoader): Try[AutoPlugin] = {
|
||||||
import sbtprojectmatrix.ReflectionUtil._
|
import ReflectionUtil.*
|
||||||
withContextClassloader(classLoader) { loader =>
|
withContextClassloader(classLoader) { loader =>
|
||||||
getSingletonObject[AutoPlugin](loader, "scala.scalanative.sbtplugin.ScalaNativePlugin$")
|
getSingletonObject[AutoPlugin](loader, "scala.scalanative.sbtplugin.ScalaNativePlugin$")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override def projectRefs: Seq[ProjectReference] =
|
override def projectRefs: Seq[ProjectReference] = componentProjects.map(p => LocalProject(p.id))
|
||||||
componentProjects map { case p => (p: ProjectReference) }
|
|
||||||
|
|
||||||
override def filterProjects(axisValues: Seq[VirtualAxis]): Seq[Project] =
|
override def filterProjects(axisValues: Seq[VirtualAxis]): Seq[Project] =
|
||||||
resolvedMappings.toSeq collect {
|
resolvedMappings.toSeq collect {
|
||||||
case (r, p) if axisValues.forall(v => r.axisValues.contains(v)) => p
|
case (r, p) if axisValues.forall(v => r.axisValues.contains(v)) => p
|
||||||
}
|
}
|
||||||
override def filterProjects(autoScalaLibrary: Boolean, axisValues: Seq[VirtualAxis]): Seq[Project] =
|
override def filterProjects(
|
||||||
|
autoScalaLibrary: Boolean,
|
||||||
|
axisValues: Seq[VirtualAxis]
|
||||||
|
): Seq[Project] =
|
||||||
resolvedMappings.toSeq collect {
|
resolvedMappings.toSeq collect {
|
||||||
case (r, p) if r.autoScalaLibrary == autoScalaLibrary && axisValues.forall(v => r.axisValues.contains(v)) => p
|
case (r, p)
|
||||||
|
if r.autoScalaLibrary == autoScalaLibrary && axisValues
|
||||||
|
.forall(v => r.axisValues.contains(v)) =>
|
||||||
|
p
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class AxisBaseProjectFinder(axisValues: Seq[VirtualAxis]) extends ProjectFinder {
|
private final class AxisBaseProjectFinder(axisValues: Seq[VirtualAxis]) extends ProjectFinder {
|
||||||
def get: Seq[Project] = filterProjects(axisValues)
|
def get: Seq[Project] = filterProjects(axisValues)
|
||||||
def apply(sv: String): Project =
|
def apply(sv: String): Project =
|
||||||
filterProjects(true, axisValues ++ Seq(VirtualAxis.scalaABIVersion(sv))).headOption
|
filterProjects(true, axisValues ++ Seq(VirtualAxis.scalaABIVersion(sv))).headOption
|
||||||
.getOrElse(sys.error(s"project matching $axisValues and $sv was not found"))
|
.getOrElse(sys.error(s"project matching $axisValues and $sv was not found"))
|
||||||
def apply(autoScalaLibrary: Boolean): Project =
|
def apply(autoScalaLibrary: Boolean): Project =
|
||||||
filterProjects(autoScalaLibrary, axisValues).headOption
|
filterProjects(autoScalaLibrary, axisValues).headOption
|
||||||
.getOrElse(sys.error(s"project matching $axisValues and $autoScalaLibrary was not found"))
|
.getOrElse(sys.error(s"project matching $axisValues and $autoScalaLibrary was not found"))
|
||||||
}
|
}
|
||||||
|
|
||||||
override def customRow(
|
override def customRow(
|
||||||
scalaVersions: Seq[String],
|
scalaVersions: Seq[String],
|
||||||
axisValues: Seq[VirtualAxis],
|
axisValues: Seq[VirtualAxis],
|
||||||
settings: Seq[Setting[_]]
|
settings: Seq[Def.Setting[_]]
|
||||||
): ProjectMatrix = customRow(true, scalaVersions, axisValues, { _.settings(settings) })
|
): ProjectMatrix = customRow(true, scalaVersions, axisValues, { _.settings(settings) })
|
||||||
|
|
||||||
override def customRow(
|
override def customRow(
|
||||||
autoScalaLibrary: Boolean,
|
autoScalaLibrary: Boolean,
|
||||||
axisValues: Seq[VirtualAxis],
|
axisValues: Seq[VirtualAxis],
|
||||||
settings: Seq[Setting[_]]
|
settings: Seq[Def.Setting[_]]
|
||||||
): ProjectMatrix = customRow(autoScalaLibrary, Nil, axisValues, { _.settings(settings) })
|
): ProjectMatrix = customRow(autoScalaLibrary, Nil, axisValues, { _.settings(settings) })
|
||||||
|
|
||||||
override def customRow(
|
override def customRow(
|
||||||
scalaVersions: Seq[String],
|
scalaVersions: Seq[String],
|
||||||
axisValues: Seq[VirtualAxis],
|
axisValues: Seq[VirtualAxis],
|
||||||
process: Project => Project
|
process: Project => Project
|
||||||
): ProjectMatrix = customRow(true, scalaVersions, axisValues, process)
|
): ProjectMatrix = customRow(true, scalaVersions, axisValues, process)
|
||||||
|
|
||||||
override def customRow(
|
override def customRow(
|
||||||
autoScalaLibrary: Boolean,
|
autoScalaLibrary: Boolean,
|
||||||
scalaVersions: Seq[String],
|
scalaVersions: Seq[String],
|
||||||
axisValues: Seq[VirtualAxis],
|
axisValues: Seq[VirtualAxis],
|
||||||
process: Project => Project
|
process: Project => Project
|
||||||
): ProjectMatrix =
|
): ProjectMatrix =
|
||||||
if (autoScalaLibrary) {
|
if (autoScalaLibrary) {
|
||||||
scalaVersions.foldLeft(this: ProjectMatrix) { (acc, sv) =>
|
scalaVersions.foldLeft(this: ProjectMatrix) { (acc, sv) =>
|
||||||
acc.customRow(autoScalaLibrary, axisValues ++ Seq(VirtualAxis.scalaABIVersion(sv)), process)
|
acc.customRow(
|
||||||
|
autoScalaLibrary,
|
||||||
|
axisValues ++ Seq(VirtualAxis.scalaABIVersion(sv)),
|
||||||
|
process
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
customRow(autoScalaLibrary, axisValues ++ Seq(VirtualAxis.jvm), process)
|
customRow(autoScalaLibrary, axisValues ++ Seq(VirtualAxis.jvm), process)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def customRow(
|
override def customRow(
|
||||||
autoScalaLibrary: Boolean,
|
autoScalaLibrary: Boolean,
|
||||||
axisValues: Seq[VirtualAxis],
|
axisValues: Seq[VirtualAxis],
|
||||||
process: Project => Project
|
process: Project => Project
|
||||||
): ProjectMatrix = {
|
): ProjectMatrix = {
|
||||||
val newRow: ProjectRow = new ProjectRow(autoScalaLibrary, axisValues, process)
|
val newRow: ProjectRow = new ProjectRow(autoScalaLibrary, axisValues, process)
|
||||||
copy(rows = this.rows :+ newRow)
|
copy(rows = this.rows :+ newRow)
|
||||||
|
|
@ -533,20 +660,20 @@ object ProjectMatrix {
|
||||||
new AxisBaseProjectFinder(axisValues.toSeq)
|
new AxisBaseProjectFinder(axisValues.toSeq)
|
||||||
|
|
||||||
override def allProjects(): Seq[(Project, Seq[VirtualAxis])] =
|
override def allProjects(): Seq[(Project, Seq[VirtualAxis])] =
|
||||||
resolvedMappings.map { case(row, project) =>
|
resolvedMappings.map { case (row, project) =>
|
||||||
project -> row.axisValues
|
project -> row.axisValues
|
||||||
}.toSeq
|
}.toSeq
|
||||||
|
|
||||||
def copy(
|
def copy(
|
||||||
id: String = id,
|
id: String = id,
|
||||||
base: sbt.File = base,
|
base: File = base,
|
||||||
scalaVersions: Seq[String] = scalaVersions,
|
scalaVersions: Seq[String] = scalaVersions,
|
||||||
rows: Seq[ProjectRow] = rows,
|
rows: Seq[ProjectRow] = rows,
|
||||||
aggregate: Seq[ProjectMatrixReference] = aggregate,
|
aggregate: Seq[ProjectMatrixReference] = aggregate,
|
||||||
nonMatrixAggregate: Seq[ProjectReference] = nonMatrixAggregate,
|
nonMatrixAggregate: Seq[ProjectReference] = nonMatrixAggregate,
|
||||||
dependencies: Seq[MatrixClasspathDep[ProjectMatrixReference]] = dependencies,
|
dependencies: Seq[MatrixClasspathDep[ProjectMatrixReference]] = dependencies,
|
||||||
nonMatrixDependencies: Seq[ClasspathDep[ProjectReference]] = nonMatrixDependencies,
|
nonMatrixDependencies: Seq[ClasspathDep[ProjectReference]] = nonMatrixDependencies,
|
||||||
settings: Seq[Setting[_]] = settings,
|
settings: Seq[Def.Setting[_]] = settings,
|
||||||
configurations: Seq[Configuration] = configurations,
|
configurations: Seq[Configuration] = configurations,
|
||||||
plugins: Plugins = plugins,
|
plugins: Plugins = plugins,
|
||||||
transforms: Seq[Project => Project] = transforms,
|
transforms: Seq[Project => Project] = transforms,
|
||||||
|
|
@ -573,16 +700,30 @@ object ProjectMatrix {
|
||||||
}
|
}
|
||||||
|
|
||||||
// called by macro
|
// called by macro
|
||||||
def apply(id: String, base: sbt.File): ProjectMatrix = {
|
def apply(id: String, base: File): ProjectMatrix = {
|
||||||
val defaultDefAxes = Seq(VirtualAxis.jvm, VirtualAxis.scalaABIVersion("2.13.3"))
|
val defaultDefAxes = Seq(VirtualAxis.jvm, VirtualAxis.scalaABIVersion("2.13.3"))
|
||||||
val matrix = unresolved(id, base, Nil, Nil, Nil, Nil, Nil, Nil, Nil, Nil, Plugins.Empty, Nil, defaultDefAxes)
|
val matrix = unresolved(
|
||||||
|
id,
|
||||||
|
base,
|
||||||
|
Nil,
|
||||||
|
Nil,
|
||||||
|
Nil,
|
||||||
|
Nil,
|
||||||
|
Nil,
|
||||||
|
Nil,
|
||||||
|
Nil,
|
||||||
|
Nil,
|
||||||
|
Plugins.Empty,
|
||||||
|
Nil,
|
||||||
|
defaultDefAxes
|
||||||
|
)
|
||||||
allMatrices(id) = matrix
|
allMatrices(id) = matrix
|
||||||
matrix
|
matrix
|
||||||
}
|
}
|
||||||
|
|
||||||
private[sbt] def unresolved(
|
private[sbt] def unresolved(
|
||||||
id: String,
|
id: String,
|
||||||
base: sbt.File,
|
base: File,
|
||||||
scalaVersions: Seq[String],
|
scalaVersions: Seq[String],
|
||||||
rows: Seq[ProjectRow],
|
rows: Seq[ProjectRow],
|
||||||
aggregate: Seq[ProjectMatrixReference],
|
aggregate: Seq[ProjectMatrixReference],
|
||||||
|
|
@ -618,16 +759,60 @@ object ProjectMatrix {
|
||||||
implicit def projectMatrixToLocalProjectMatrix(m: ProjectMatrix): LocalProjectMatrix =
|
implicit def projectMatrixToLocalProjectMatrix(m: ProjectMatrix): LocalProjectMatrix =
|
||||||
LocalProjectMatrix(m.id)
|
LocalProjectMatrix(m.id)
|
||||||
|
|
||||||
import scala.reflect.macros._
|
private object ReflectionUtil:
|
||||||
|
def getSingletonObject[A: ClassTag](classLoader: ClassLoader, className: String): Try[A] =
|
||||||
|
Try {
|
||||||
|
val clazz = classLoader.loadClass(className)
|
||||||
|
val t = implicitly[ClassTag[A]].runtimeClass
|
||||||
|
Option(clazz.getField("MODULE$").get(null)) match {
|
||||||
|
case None =>
|
||||||
|
throw new ClassNotFoundException(
|
||||||
|
s"Unable to find $className using classloader: $classLoader"
|
||||||
|
)
|
||||||
|
case Some(c) if !t.isInstance(c) =>
|
||||||
|
throw new ClassCastException(s"${clazz.getName} is not a subtype of $t")
|
||||||
|
case Some(c) => c.asInstanceOf[A]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.recover {
|
||||||
|
case i: InvocationTargetException if i.getTargetException != null =>
|
||||||
|
throw i.getTargetException
|
||||||
|
}
|
||||||
|
|
||||||
def projectMatrixMacroImpl(c: blackbox.Context): c.Expr[ProjectMatrix] = {
|
def objectExists(classLoader: ClassLoader, className: String): Boolean =
|
||||||
import c.universe._
|
try {
|
||||||
val enclosingValName = std.KeyMacro.definingValName(
|
classLoader.loadClass(className).getField("MODULE$").get(null) != null
|
||||||
c,
|
} catch {
|
||||||
methodName =>
|
case _: Throwable => false
|
||||||
s"""$methodName must be directly assigned to a val, such as `val x = $methodName`. Alternatively, you can use `sbt.ProjectMatrix.apply`"""
|
}
|
||||||
|
|
||||||
|
def withContextClassloader[A](loader: ClassLoader)(body: ClassLoader => A): A = {
|
||||||
|
val current = Thread.currentThread().getContextClassLoader
|
||||||
|
try {
|
||||||
|
Thread.currentThread().setContextClassLoader(loader)
|
||||||
|
body(loader)
|
||||||
|
} finally Thread.currentThread().setContextClassLoader(current)
|
||||||
|
}
|
||||||
|
end ReflectionUtil
|
||||||
|
|
||||||
|
def projectMatrixImpl(using Quotes): Expr[ProjectMatrix] = {
|
||||||
|
val name = std.KeyMacro.definingValName(
|
||||||
|
"projectMatrix must be directly assigned to a val, such as `val x = projectMatrix`. Alternatively, you can use `sbt.ProjectMatrix.apply`"
|
||||||
)
|
)
|
||||||
val name = c.Expr[String](Literal(Constant(enclosingValName)))
|
'{ ProjectMatrix($name, new File($name)) }
|
||||||
reify { ProjectMatrix(name.splice, new sbt.File(name.splice)) }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trait ProjectMatrixExtra:
|
||||||
|
given Conversion[ProjectMatrix, LocalProjectMatrix] =
|
||||||
|
m => LocalProjectMatrix(m.id)
|
||||||
|
|
||||||
|
given [A](using
|
||||||
|
Conversion[A, ProjectMatrixReference]
|
||||||
|
): Conversion[A, ProjectMatrix.MatrixClasspathDependency] =
|
||||||
|
ref => ProjectMatrix.MatrixClasspathDependency(ref, None)
|
||||||
|
|
||||||
|
given [A](using
|
||||||
|
Conversion[A, ProjectMatrixReference]
|
||||||
|
): Conversion[A, ProjectMatrix.ProjectMatrixReferenceSyntax] =
|
||||||
|
ref => ProjectMatrix.ProjectMatrixReferenceSyntax(ref)
|
||||||
|
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
package sbt
|
|
||||||
|
|
||||||
import sbt._
|
|
||||||
import internal._
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
|
||||||
import scala.language.experimental.macros
|
|
||||||
|
|
||||||
trait ProjectMatrixKeys {
|
|
||||||
val virtualAxes = settingKey[Seq[VirtualAxis]]("Virtual axes for the project")
|
|
||||||
val projectMatrixBaseDirectory = settingKey[File]("Base directory of the current project matrix")
|
|
||||||
}
|
|
||||||
|
|
||||||
object ProjectMatrixKeys extends ProjectMatrixKeys
|
|
||||||
|
|
||||||
object ProjectMatrixPlugin extends AutoPlugin {
|
|
||||||
override val requires = sbt.plugins.CorePlugin
|
|
||||||
override val trigger = allRequirements
|
|
||||||
object autoImport extends ProjectMatrixKeys {
|
|
||||||
def projectMatrix: ProjectMatrix = macro ProjectMatrix.projectMatrixMacroImpl
|
|
||||||
|
|
||||||
implicit def matrixClasspathDependency[T](
|
|
||||||
m: T
|
|
||||||
)(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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
package sbt
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException
|
|
||||||
import scala.reflect.ClassTag
|
|
||||||
import scala.util.Try
|
|
||||||
|
|
||||||
object ReflectionUtil {
|
|
||||||
def getSingletonObject[A: ClassTag](classLoader: ClassLoader, className: String): Try[A] =
|
|
||||||
Try {
|
|
||||||
val clazz = classLoader.loadClass(className)
|
|
||||||
val t = implicitly[ClassTag[A]].runtimeClass
|
|
||||||
Option(clazz.getField("MODULE$").get(null)) match {
|
|
||||||
case None =>
|
|
||||||
throw new ClassNotFoundException(
|
|
||||||
s"Unable to find $className using classloader: $classLoader"
|
|
||||||
)
|
|
||||||
case Some(c) if !t.isInstance(c) =>
|
|
||||||
throw new ClassCastException(s"${clazz.getName} is not a subtype of $t")
|
|
||||||
case Some(c: A) => c
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.recover {
|
|
||||||
case i: InvocationTargetException if i.getTargetException != null =>
|
|
||||||
throw i.getTargetException
|
|
||||||
}
|
|
||||||
|
|
||||||
def objectExists(classLoader: ClassLoader, className: String): Boolean =
|
|
||||||
try {
|
|
||||||
classLoader.loadClass(className).getField("MODULE$").get(null) != null
|
|
||||||
} catch {
|
|
||||||
case _: Throwable => false
|
|
||||||
}
|
|
||||||
|
|
||||||
def withContextClassloader[A](loader: ClassLoader)(body: ClassLoader => A): A = {
|
|
||||||
val current = Thread.currentThread().getContextClassLoader
|
|
||||||
try {
|
|
||||||
Thread.currentThread().setContextClassLoader(loader)
|
|
||||||
body(loader)
|
|
||||||
} finally Thread.currentThread().setContextClassLoader(current)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
package sbt
|
||||||
|
package internal
|
||||||
|
|
||||||
|
/** Identifies a project matrix. */
|
||||||
|
sealed trait ProjectMatrixReference
|
||||||
|
|
||||||
|
/** Identifies a project in the current build context. */
|
||||||
|
final case class LocalProjectMatrix(id: String) extends ProjectMatrixReference
|
||||||
|
|
@ -18,6 +18,7 @@ package object sbt
|
||||||
with sbt.std.TaskExtra
|
with sbt.std.TaskExtra
|
||||||
// with sbt.internal.util.Types
|
// with sbt.internal.util.Types
|
||||||
with sbt.ProjectExtra
|
with sbt.ProjectExtra
|
||||||
|
with sbt.ProjectMatrixExtra
|
||||||
with sbt.librarymanagement.DependencyBuilders
|
with sbt.librarymanagement.DependencyBuilders
|
||||||
with sbt.librarymanagement.DependencyFilterExtra
|
with sbt.librarymanagement.DependencyFilterExtra
|
||||||
with sbt.librarymanagement.LibraryManagementSyntax
|
with sbt.librarymanagement.LibraryManagementSyntax
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ ThisBuild / publishMavenStyle := true
|
||||||
|
|
||||||
ThisBuild / ivyPaths := {
|
ThisBuild / ivyPaths := {
|
||||||
val base = (ThisBuild / baseDirectory).value
|
val base = (ThisBuild / baseDirectory).value
|
||||||
IvyPaths(base, Some(base / "ivy-cache"))
|
IvyPaths(base.toString, s"$base/ivy-cache")
|
||||||
}
|
}
|
||||||
publish / skip := true
|
publish / skip := true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +1 @@
|
||||||
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" % "1.3.0")
|
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.3.0")
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ ThisBuild / publishMavenStyle := true
|
||||||
|
|
||||||
ThisBuild / ivyPaths := {
|
ThisBuild / ivyPaths := {
|
||||||
val base = (ThisBuild / baseDirectory).value
|
val base = (ThisBuild / baseDirectory).value
|
||||||
IvyPaths(base, Some(base / "ivy-cache"))
|
IvyPaths(base.toString, s"$base/ivy-cache")
|
||||||
}
|
}
|
||||||
publish / skip := true
|
publish / skip := true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1 @@
|
||||||
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")
|
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.27")
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
package example
|
|
||||||
|
|
||||||
object D {
|
|
||||||
val x = C.x
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
package example
|
|
||||||
|
|
||||||
object C {
|
|
||||||
val x = 1
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
package example
|
|
||||||
|
|
||||||
object F {
|
|
||||||
val x = E.x
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
package example
|
|
||||||
|
|
||||||
object E {
|
|
||||||
val x = 1
|
|
||||||
}
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
lazy val check = taskKey[Unit]("")
|
|
||||||
lazy val scala3M1 = "3.0.0-M1"
|
|
||||||
lazy val scala3M2 = "3.0.0-M2"
|
|
||||||
lazy val scala213 = "2.13.4"
|
|
||||||
|
|
||||||
lazy val fooApp = (projectMatrix in file("foo-app"))
|
|
||||||
.dependsOn(fooCore)
|
|
||||||
.settings(
|
|
||||||
name := "foo app",
|
|
||||||
)
|
|
||||||
.jvmPlatform(scalaVersions = Seq(scala3M1, scala3M2))
|
|
||||||
|
|
||||||
lazy val fooApp3 = fooApp.jvm(scala3M1)
|
|
||||||
.settings(
|
|
||||||
test := { () },
|
|
||||||
)
|
|
||||||
|
|
||||||
lazy val fooCore = (projectMatrix in file("foo-core"))
|
|
||||||
.settings(
|
|
||||||
name := "foo core",
|
|
||||||
)
|
|
||||||
.jvmPlatform(scalaVersions = Seq(scala213, "2.12.12"))
|
|
||||||
|
|
||||||
lazy val barApp = (projectMatrix in file("bar-app"))
|
|
||||||
.dependsOn(barCore)
|
|
||||||
.settings(
|
|
||||||
name := "bar app",
|
|
||||||
)
|
|
||||||
.jvmPlatform(scalaVersions = Seq(scala213))
|
|
||||||
|
|
||||||
lazy val barCore = (projectMatrix in file("bar-core"))
|
|
||||||
.settings(
|
|
||||||
name := "bar core",
|
|
||||||
)
|
|
||||||
.jvmPlatform(scalaVersions = Seq(scala3M2))
|
|
||||||
|
|
||||||
// choose 2.13 when bazCore offers both 2.13 and Dotty
|
|
||||||
lazy val bazApp = (projectMatrix in file("baz-app"))
|
|
||||||
.dependsOn(bazCore)
|
|
||||||
.settings(
|
|
||||||
name := "baz app",
|
|
||||||
check := {
|
|
||||||
val cp = (Compile / fullClasspath).value
|
|
||||||
.map(_.data.getName)
|
|
||||||
|
|
||||||
assert(cp.contains("baz-core_2.13-0.1.0-SNAPSHOT.jar"), s"$cp")
|
|
||||||
assert(!cp.contains("baz-core_3.0.0-M1-0.1.0-SNAPSHOT.jar"), s"$cp")
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.jvmPlatform(scalaVersions = Seq(scala213))
|
|
||||||
|
|
||||||
lazy val bazCore = (projectMatrix in file("baz-core"))
|
|
||||||
.settings(
|
|
||||||
name := "baz core",
|
|
||||||
exportJars := true,
|
|
||||||
)
|
|
||||||
.jvmPlatform(scalaVersions = Seq(scala213, scala3M1))
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
package example
|
|
||||||
|
|
||||||
object B {
|
|
||||||
val x = A.x
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
package example
|
|
||||||
|
|
||||||
object A {
|
|
||||||
val x = 1
|
|
||||||
}
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
sbt.version=1.4.2
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
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("ch.epfl.lamp" % "sbt-dotty" % "0.4.5")
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
> projects
|
|
||||||
|
|
||||||
> fooApp3_0_0_M1/compile
|
|
||||||
|
|
||||||
> barApp/compile
|
|
||||||
|
|
||||||
> bazApp/check
|
|
||||||
|
|
@ -35,12 +35,9 @@ lazy val bazApp = (projectMatrix in file("baz-app"))
|
||||||
.settings(
|
.settings(
|
||||||
name := "baz app",
|
name := "baz app",
|
||||||
check := {
|
check := {
|
||||||
val cp = (Compile / fullClasspath).value
|
val cp = (Compile / fullClasspath).value.map(_.data.id)
|
||||||
.map(_.data.getName)
|
assert(cp.exists(_.endsWith("baz-core_2.13-0.1.0-SNAPSHOT.jar")), cp)
|
||||||
|
assert(!cp.exists(_.endsWith("baz-core_3.0.0-M1-0.1.0-SNAPSHOT.jar")), cp)
|
||||||
streams.value.log.info(cp.toString)
|
|
||||||
assert(cp.contains("baz-core_2.13-0.1.0-SNAPSHOT.jar"), s"$cp")
|
|
||||||
assert(!cp.contains("baz-core_3.0.0-M1-0.1.0-SNAPSHOT.jar"), s"$cp")
|
|
||||||
assert(projectMatrixBaseDirectory.value == file("baz-app"))
|
assert(projectMatrixBaseDirectory.value == file("baz-app"))
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
sbt.version=1.4.2
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
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("ch.epfl.lamp" % "sbt-dotty" % "0.4.5")
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
import sbt.internal.ProjectMatrix
|
|
||||||
ThisBuild / organization := "com.example"
|
ThisBuild / organization := "com.example"
|
||||||
ThisBuild / version := "0.1.0-SNAPSHOT"
|
ThisBuild / version := "0.1.0-SNAPSHOT"
|
||||||
ThisBuild / publishMavenStyle := true
|
ThisBuild / publishMavenStyle := true
|
||||||
|
|
||||||
ThisBuild / ivyPaths := {
|
ThisBuild / ivyPaths := {
|
||||||
val base = (ThisBuild / baseDirectory).value
|
val base = (ThisBuild / baseDirectory).value
|
||||||
IvyPaths(base, Some(base / "ivy-cache"))
|
IvyPaths(base.toString, s"$base/ivy-cache")
|
||||||
}
|
}
|
||||||
publish / skip := true
|
publish / skip := true
|
||||||
|
|
||||||
|
|
@ -26,13 +25,14 @@ check := {
|
||||||
lazy val app: ProjectMatrix = (projectMatrix in file("app"))
|
lazy val app: ProjectMatrix = (projectMatrix in file("app"))
|
||||||
.settings(
|
.settings(
|
||||||
name := "app",
|
name := "app",
|
||||||
ivyPaths := (ThisBuild / ivyPaths).value
|
ivyPaths := (ThisBuild / ivyPaths).value,
|
||||||
|
scalaVersion := scala212
|
||||||
)
|
)
|
||||||
.aggregate(domain)
|
.aggregate(domain)
|
||||||
.dependsOn(domain)
|
.dependsOn(domain)
|
||||||
.customRow(
|
.customRow(
|
||||||
autoScalaLibrary = false,
|
autoScalaLibrary = false,
|
||||||
scalaVersions = Seq(scala212),
|
scalaVersions = Seq(),
|
||||||
axisValues = Seq(config12, VirtualAxis.jvm),
|
axisValues = Seq(config12, VirtualAxis.jvm),
|
||||||
_.settings(
|
_.settings(
|
||||||
libraryDependencies += "com.typesafe" % "config" % "1.2.1"
|
libraryDependencies += "com.typesafe" % "config" % "1.2.1"
|
||||||
|
|
@ -40,7 +40,7 @@ lazy val app: ProjectMatrix = (projectMatrix in file("app"))
|
||||||
)
|
)
|
||||||
.customRow(
|
.customRow(
|
||||||
autoScalaLibrary = false,
|
autoScalaLibrary = false,
|
||||||
scalaVersions = Seq(scala212),
|
scalaVersions = Seq(),
|
||||||
axisValues = Seq(config13, VirtualAxis.jvm),
|
axisValues = Seq(config13, VirtualAxis.jvm),
|
||||||
_.settings(
|
_.settings(
|
||||||
libraryDependencies += "com.typesafe" % "config" % "1.3.3"
|
libraryDependencies += "com.typesafe" % "config" % "1.3.3"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
> compile
|
> compile
|
||||||
|
|
||||||
$ exists domain/target/scala-2.12/classes/a/DataType.class
|
$ exists target/out/jvm/scala-2.12.10/domain/backend/a/DataType.class
|
||||||
|
|
||||||
> check
|
> check
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
> compile
|
> compile
|
||||||
|
|
||||||
$ exists core/target/jvm-2.13/classes/a/Core.class
|
$ exists target/out/jvm/scala-2.13.3/core/backend/a/Core.class
|
||||||
$ exists core/target/jvm-2.12/classes/a/Core.class
|
$ exists target/out/jvm/scala-2.12.12/core/backend/a/Core.class
|
||||||
|
|
||||||
> core/check
|
> core/check
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
sbt.version=2.0.0-alpha12-SNAPSHOT
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
> compile
|
> compile
|
||||||
|
|
||||||
$ exists core/target/jvm-2.13/classes/a/Core.class
|
$ exists target/out/jvm/scala-2.13.3/core/backend/a/Core.class
|
||||||
$ exists core/target/jvm-2.12/classes/a/Core.class
|
$ exists target/out/jvm/scala-2.12.12/core/backend/a/Core.class
|
||||||
|
|
||||||
> core/check
|
> core/check
|
||||||
|
|
|
||||||
|
|
@ -13,3 +13,4 @@ lazy val ss = projectMatrix
|
||||||
.jvmPlatform(scalaVersions = Seq("2.13.13"))
|
.jvmPlatform(scalaVersions = Seq("2.13.13"))
|
||||||
|
|
||||||
lazy val strayJar = project
|
lazy val strayJar = project
|
||||||
|
.settings(scalaVersion := "2.12.19")
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
@ -6,10 +6,10 @@
|
||||||
|
|
||||||
# check root
|
# check root
|
||||||
$ mkdir lib
|
$ mkdir lib
|
||||||
$ copy-file strayJar/target/scala-2.12/strayjar_2.12-0.1.0-SNAPSHOT.jar lib/strayJar.jar
|
$ copy-file target/out/jvm/scala-2.12.19/strayjar/strayjar_2.12-0.1.0-SNAPSHOT.jar lib/strayJar.jar
|
||||||
> root2_12/compile
|
> root2_12/compile
|
||||||
|
|
||||||
# check ss
|
# check ss
|
||||||
$ mkdir ss/lib
|
$ mkdir ss/lib
|
||||||
$ copy-file strayJar/target/scala-2.12/strayjar_2.12-0.1.0-SNAPSHOT.jar ss/lib/strayJar.jar
|
$ copy-file target/out/jvm/scala-2.12.19/strayjar/strayjar_2.12-0.1.0-SNAPSHOT.jar ss/lib/strayJar.jar
|
||||||
> ss/compile
|
> ss/compile
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
sbt.version = 1.4.3
|
|
||||||
|
|
@ -1,6 +1 @@
|
||||||
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-native" % "sbt-scala-native" % "0.4.0")
|
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0")
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1 @@
|
||||||
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" % "1.3.0")
|
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.3.0")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue