Skip to content

Commit

Permalink
Merge pull request #591 from armanbilge/topic/deprecate-tlSkipIrrelev…
Browse files Browse the repository at this point in the history
…antScalas

Deprecate `tlSkipIrrelevantScalas`
  • Loading branch information
armanbilge authored Jul 5, 2023
2 parents 1f6850a + f1c5423 commit 8b896b4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 39 deletions.
5 changes: 4 additions & 1 deletion ci/src/main/scala/org/typelevel/sbt/CrossRootProject.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package org.typelevel.sbt
import org.typelevel.sbt.gha.GenerativePlugin.autoImport._
import sbt._

import Keys._

/**
* Simultaneously creates a root project, a Scala JVM aggregate project, a Scala.js aggregate
* project, a Scala Native aggregate project and automatically enables the `NoPublishPlugin`.
Expand Down Expand Up @@ -132,7 +134,8 @@ object CrossRootProject {
Some((rootProject.all, rootProject.jvm, rootProject.js, rootProject.native))

def apply(id: String): CrossRootProject = new CrossRootProject(
Project(id, file(".")),
Project(id, file("."))
.settings(crossScalaVersions := Nil, scalaVersion := (ThisBuild / scalaVersion).value),
Project(s"${id}JVM", file(".jvm")),
Project(s"${id}JS", file(".js")),
Project(s"${id}Native", file(".native"))
Expand Down
1 change: 0 additions & 1 deletion docs/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Instead of using the super-plugins, for finer-grained control you can always add
`TypelevelKernelPlugin`

- `tlIsScala3` (setting): `true`, if `scalaVersion` is 3.x.
- `tlSkipIrrelevantScalas` (setting): `true`, if should `skip` for `scalaVersion` not in `crossScalaVersions`.
- `tlReplaceCommandAlias` (method): Replace a `addCommandAlias` definition.
- `tlReleaseLocal` (command): Alias for `+publishLocal`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ object TypelevelKernelPlugin extends AutoPlugin {
lazy val CompileTime: Configuration = config("compile-time").hide

lazy val tlIsScala3 = settingKey[Boolean]("True if building with Scala 3")

@deprecated(
"No longer has an effect. Use tlCrossRootProject for your root project.",
"0.5.0")
lazy val tlSkipIrrelevantScalas = settingKey[Boolean](
"Sets skip := true for compile/test/publish/etc. tasks on a project if the current scalaVersion is not in that project's crossScalaVersions (default: false)")

Expand All @@ -51,45 +55,15 @@ object TypelevelKernelPlugin extends AutoPlugin {
)

override def buildSettings =
Seq(tlSkipIrrelevantScalas := false) ++
addCommandAlias("tlReleaseLocal", mkCommand(List("reload", "project /", "+publishLocal")))
addCommandAlias("tlReleaseLocal", mkCommand(List("reload", "project /", "+publishLocal")))

override def projectSettings = Seq(
ivyConfigurations += CompileTime,
Compile / unmanagedClasspath ++= update.value.select(configurationFilter(CompileTime.name)),
(Test / test) := {
if (tlSkipIrrelevantScalas.value && (Test / test / skip).value)
()
else (Test / test).value
},
(Compile / doc) := {
if (tlSkipIrrelevantScalas.value && (Compile / doc / skip).value)
(Compile / doc / target).value
else (Compile / doc).value
},
skipIfIrrelevant(compile),
skipIfIrrelevant(test),
skipIfIrrelevant(doc),
skipIfIrrelevant(publishLocal),
skipIfIrrelevant(publish)
Compile / unmanagedClasspath ++= update.value.select(configurationFilter(CompileTime.name))
)

private[sbt] def mkCommand(commands: List[String]): String = commands.mkString("; ", "; ", "")

/**
* A setting that will make a task respect the `tlSkipIrrelevantScalas` setting. Note that the
* task itself must respect `skip` for this to take effect.
*/
def skipIfIrrelevant[T](task: TaskKey[T]) = {
task / skip := {
(task / skip).value || {
val cross = crossScalaVersions.value
val ver = (LocalRootProject / scalaVersion).value
(task / tlSkipIrrelevantScalas).value && !cross.contains(ver)
}
}
}

private[sbt] lazy val currentRelease: Def.Initialize[Option[String]] = Def.setting {
// some tricky logic here ...
// if the latest release is a pre-release (e.g., M or RC)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ object TypelevelMimaPlugin extends AutoPlugin {
}

import autoImport._
import TypelevelKernelPlugin.autoImport._
import TypelevelKernelPlugin.skipIfIrrelevant

override def buildSettings = Seq[Setting[_]](
tlVersionIntroduced := Map.empty,
Expand All @@ -65,11 +63,9 @@ object TypelevelMimaPlugin extends AutoPlugin {

override def projectSettings = Seq[Setting[_]](
mimaReportBinaryIssues := {
if (!publishArtifact.value || (tlSkipIrrelevantScalas.value && (mimaReportBinaryIssues / skip).value))
()
if (!publishArtifact.value) ()
else mimaReportBinaryIssues.value
},
skipIfIrrelevant(mimaReportBinaryIssues),
tlMimaPreviousVersions := {
val introduced = tlVersionIntroduced
.value
Expand Down

0 comments on commit 8b896b4

Please sign in to comment.