Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ object TypelevelKernelPlugin extends AutoPlugin {
object autoImport {
lazy val tlIsScala3 = settingKey[Boolean]("True if building with Scala 3")

lazy val tlPublishIfRelevant = taskKey[Unit](
"A wrapper around the `publish` task which checks to ensure the current scalaVersion is in crossScalaVersions")

lazy val tlPublishLocalIfRelevant = taskKey[Unit](
"A wrapper around the `publishLocal` task which checks to ensure the current scalaVersion is in crossScalaVersions")

def tlReplaceCommandAlias(name: String, contents: String): Seq[Setting[State => State]] =
Seq(GlobalScope / onLoad ~= { (f: State => State) =>
f andThen { s: State =>
Expand All @@ -42,8 +48,28 @@ object TypelevelKernelPlugin extends AutoPlugin {
)

override def buildSettings =
addCommandAlias("tlReleaseLocal", mkCommand(List("reload", "project /", "+publishLocal")))
addCommandAlias(
"tlReleaseLocal",
mkCommand(List("reload", "project /", "+tlPublishLocalIfRelevant")))

override def projectSettings = Seq(
tlPublishIfRelevant := filterTaskWhereRelevant(publish).value,
tlPublishLocalIfRelevant := filterTaskWhereRelevant(publishLocal).value
)

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

private[sbt] def filterTaskWhereRelevant(delegate: TaskKey[Unit]) =
Def.taskDyn {
val cross = crossScalaVersions.value
val ver = (ThisBuild / scalaVersion).value

if (cross.contains(ver))
Def.task(delegate.value)
else {
val msg = s"skipping `${delegate.key.label}` in ${name.value}: $ver is not in $cross"
Def.task(streams.value.log.info(msg))
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package org.typelevel.sbt
import sbt._, Keys._
import com.typesafe.tools.mima.plugin.MimaPlugin
import xerial.sbt.Sonatype, Sonatype.autoImport._
import TypelevelKernelPlugin.mkCommand
import TypelevelKernelPlugin._

object TypelevelSonatypePlugin extends AutoPlugin {

Expand All @@ -30,9 +30,13 @@ object TypelevelSonatypePlugin extends AutoPlugin {
object autoImport {
lazy val tlSonatypeUseLegacyHost =
settingKey[Boolean]("Publish to oss.sonatype.org instead of s01 (default: true)")

lazy val tlMimaReportBinaryIssuesIfRelevant = taskKey[Unit](
"A wrapper around the `mimaReportBinaryIssues` task which checks to ensure the current scalaVersion is in crossScalaVersions")
}

import autoImport._
import MimaPlugin.autoImport._

override def buildSettings =
Seq(tlSonatypeUseLegacyHost := true) ++
Expand All @@ -42,8 +46,8 @@ object TypelevelSonatypePlugin extends AutoPlugin {
List(
"reload",
"project /",
"+mimaReportBinaryIssues",
"+publish",
"+tlMimaReportBinaryIssuesIfRelevant",
"+tlPublishIfRelevant",
"tlSonatypeBundleReleaseIfRelevant"))
)

Expand All @@ -57,7 +61,8 @@ object TypelevelSonatypePlugin extends AutoPlugin {
"oss.sonatype.org"
else
"s01.oss.sonatype.org"
}
},
tlMimaReportBinaryIssuesIfRelevant := filterTaskWhereRelevant(mimaReportBinaryIssues).value
)

private def sonatypeBundleReleaseIfRelevant: Command =
Expand Down