Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bikeshedding #80

Merged
merged 1 commit into from
Jan 18, 2022
Merged
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
59 changes: 31 additions & 28 deletions ci/src/main/scala/org/typelevel/sbt/CrossRootProject.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,44 +24,44 @@ import org.typelevel.sbt.gha.GenerativePlugin.autoImport._
* automatically enables the `NoPublishPlugin`.
*/
final class CrossRootProject private (
val root: Project,
val rootJVM: Project,
val rootJS: Project,
val rootNative: Project
val all: Project,
val jvm: Project,
val js: Project,
val native: Project
) extends CompositeProject {

override def componentProjects: Seq[Project] = Seq(root, rootJVM, rootJS, rootNative)
override def componentProjects: Seq[Project] = Seq(all, jvm, js, native)

def settings(ss: Def.SettingsDefinition*): CrossRootProject =
new CrossRootProject(
root.settings(ss: _*),
rootJVM.settings(ss: _*),
rootJS.settings(ss: _*),
rootNative.settings(ss: _*)
all.settings(ss: _*),
jvm.settings(ss: _*),
js.settings(ss: _*),
native.settings(ss: _*)
)

def configure(transforms: (Project => Project)*): CrossRootProject =
new CrossRootProject(
root.configure(transforms: _*),
rootJVM.configure(transforms: _*),
rootJS.configure(transforms: _*),
rootNative.configure(transforms: _*)
all.configure(transforms: _*),
jvm.configure(transforms: _*),
js.configure(transforms: _*),
native.configure(transforms: _*)
)

def enablePlugins(ns: Plugins*): CrossRootProject =
new CrossRootProject(
root.enablePlugins(ns: _*),
rootJVM.enablePlugins(ns: _*),
rootJS.enablePlugins(ns: _*),
rootNative.enablePlugins(ns: _*)
all.enablePlugins(ns: _*),
jvm.enablePlugins(ns: _*),
js.enablePlugins(ns: _*),
native.enablePlugins(ns: _*)
)

def disablePlugins(ps: AutoPlugin*): CrossRootProject =
new CrossRootProject(
root.disablePlugins(ps: _*),
rootJVM.disablePlugins(ps: _*),
rootJS.disablePlugins(ps: _*),
rootNative.disablePlugins(ps: _*)
all.disablePlugins(ps: _*),
jvm.disablePlugins(ps: _*),
js.disablePlugins(ps: _*),
native.disablePlugins(ps: _*)
)

def aggregate(projects: CompositeProject*): CrossRootProject =
Expand All @@ -78,24 +78,27 @@ final class CrossRootProject private (
val jvmProjects = projects.diff(jsProjects).diff(nativeProjects)

new CrossRootProject(
root.aggregate(projects.map(_.project): _*),
all.aggregate(projects.map(_.project): _*),
if (jvmProjects.nonEmpty)
rootJVM.aggregate(jvmProjects.map(_.project): _*).enablePlugins(TypelevelCiJVMPlugin)
else rootJVM,
jvm.aggregate(jvmProjects.map(_.project): _*).enablePlugins(TypelevelCiJVMPlugin)
else jvm,
if (jsProjects.nonEmpty)
rootJS.aggregate(jsProjects.map(_.project): _*).enablePlugins(TypelevelCiJSPlugin)
else rootJS,
js.aggregate(jsProjects.map(_.project): _*).enablePlugins(TypelevelCiJSPlugin)
else js,
if (nativeProjects.nonEmpty)
rootNative
native
.aggregate(nativeProjects.map(_.project): _*)
.enablePlugins(TypelevelCiNativePlugin)
else rootNative
else native
)
}

}

object CrossRootProject {
def unapply(root: CrossRootProject): Some[(Project, Project, Project, Project)] =
Some((root.all, root.jvm, root.js, root.native))

private[sbt] def apply(): CrossRootProject = new CrossRootProject(
Project("root", file(".")),
Project("rootJVM", file(".jvm")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object TypelevelGitHubPlugin extends AutoPlugin {
homepage := homepage.value.orElse(scmInfo.value.map(_.browseUrl))
)

def getScmInfo(): Option[ScmInfo] = {
private def getScmInfo(): Option[ScmInfo] = {
import scala.sys.process._

def gitHubScmInfo(user: String, repo: String) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ object TypelevelKernelPlugin extends AutoPlugin {
override def buildSettings =
addCommandAlias("tlReleaseLocal", mkCommand(List("reload", "project /", "+publishLocal")))

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import scala.util.Try

import scala.sys.process._

object GitHelper {
private[sbt] object GitHelper {

/**
* Returns a list of strictly previous releases (i.e. ignores tags on HEAD).
Expand Down
4 changes: 2 additions & 2 deletions kernel/src/main/scala/org/typelevel/sbt/kernel/V.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package org.typelevel.sbt.kernel

import scala.util.Try

final case class V(
private[sbt] final case class V(
major: Int,
minor: Int,
patch: Option[Int],
Expand Down Expand Up @@ -61,7 +61,7 @@ final case class V(

}

object V {
private[sbt] object V {
val version = """^(0|[1-9]\d*)\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:-(.+))?$""".r

def apply(v: String): Option[V] = V.unapply(v)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object TypelevelSonatypePlugin extends AutoPlugin {
"project /",
"+mimaReportBinaryIssues",
"+publish",
"sonatypeBundleReleaseIfRelevant"))
"tlSonatypeBundleReleaseIfRelevant"))
)

override def projectSettings = Seq(
Expand All @@ -61,7 +61,7 @@ object TypelevelSonatypePlugin extends AutoPlugin {
)

private def sonatypeBundleReleaseIfRelevant: Command =
Command.command("sonatypeBundleReleaseIfRelevant") { state =>
Command.command("tlSonatypeBundleReleaseIfRelevant") { state =>
if (state.getSetting(isSnapshot).getOrElse(false))
state // a snapshot is good-to-go
else // a non-snapshot releases as a bundle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ object TypelevelVersioningPlugin extends AutoPlugin {
}
)

val Description = """^.*-(\d+)-[a-zA-Z0-9]+$""".r
private val Description = """^.*-(\d+)-[a-zA-Z0-9]+$""".r

def getTaggedVersion(tags: Seq[String]): Option[V] =
private def getTaggedVersion(tags: Seq[String]): Option[V] =
tags.collect { case V.Tag(v) => v }.headOption

}