-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove coupling to sbt-projectmatrix
- Loading branch information
1 parent
97eb494
commit 76868f2
Showing
4 changed files
with
56 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import sbt._ | ||
import sbt.internal.ProjectMatrix | ||
import sbtprojectmatrix.ProjectMatrixPlugin.autoImport._ | ||
|
||
/** Use on ProjectMatrix rows to tag an affinity to a custom scalaVersion */ | ||
case class TargetAxis(scalaVersion: String) extends VirtualAxis.WeakAxis { | ||
|
||
private val scalaBinaryVersion = CrossVersion.binaryScalaVersion(scalaVersion) | ||
|
||
override val idSuffix = s"Target${scalaBinaryVersion.replace('.', '_')}" | ||
override val directorySuffix = s"target$scalaBinaryVersion" | ||
} | ||
|
||
object TargetAxis { | ||
|
||
private def targetScalaVersion(virtualAxes: Seq[VirtualAxis]): String = | ||
virtualAxes.collectFirst { case a: TargetAxis => a.scalaVersion }.get | ||
|
||
/** When invoked on a ProjectMatrix with a TargetAxis, lookup the project | ||
* generated by `matrix` with a scalaVersion matching the one defined in that | ||
* and resolve `key`. | ||
*/ | ||
def resolve[T]( | ||
matrix: ProjectMatrix, | ||
key: TaskKey[T] | ||
): Def.Initialize[Task[T]] = | ||
Def.taskDyn { | ||
val sv = targetScalaVersion(virtualAxes.value) | ||
val project = matrix.finder().apply(sv) | ||
Def.task((project / key).value) | ||
} | ||
|
||
/** When invoked on a ProjectMatrix with a TargetAxis, lookup the project | ||
* generated by `matrix` with a scalaVersion matching the one defined in that | ||
* and resolve `key`. | ||
*/ | ||
def resolve[T]( | ||
matrix: ProjectMatrix, | ||
key: SettingKey[T] | ||
): Def.Initialize[T] = | ||
Def.settingDyn { | ||
val sv = targetScalaVersion(virtualAxes.value) | ||
val project = matrix.finder().apply(sv) | ||
Def.setting((project / key).value) | ||
} | ||
|
||
} |