Skip to content

Commit

Permalink
Make the project zio.cli.sbt/sbt-zio-cli publishable by default (#209)
Browse files Browse the repository at this point in the history
* Make the project `zio.cli.sbt/sbt-zio-cli` publishable by default

Currently, `zio.cli.sbt/sbt-zio-cli` is not published in maven.

* Fix CI build

Upgrade dotty to 3.3.0 to match other zio packages.

Use `++version` instead of `++verison!` in the CI,
because the latter syntax forces a Scala version for all
subprojects ignoring the compatible versions declared in crossScalaVersions.

For example; `++3.3.0!` would force the sbt plugin to compile with
Scala version 3.3.0, while ++3.3.0 would recognize that the project
is incompatible with dotty and skip it.

It is crucial to only build the sbt plugin with Scala version 2.12,
which is what sbt 1 itself is built with.

* Automatic formatting with `sbt fmt`

To make the CI happy.
  • Loading branch information
abcpro1 authored Jun 20, 2023
1 parent 6f6e78d commit 5118158
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 27 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ jobs:
java-version: ${{ matrix.java }}
check-latest: true
- name: Run tests
if: ${{ !startsWith(matrix.scala, '3.2.') }}
run: sbt ++${{ matrix.scala }}! test
if: ${{ !startsWith(matrix.scala, '3.') }}
run: sbt "++${{ matrix.scala }} test"
- name: Run dotty tests
if: ${{ startsWith(matrix.scala, '3.2.') && matrix.platform == 'JVM' }}
run: sbt ++${{ matrix.scala }}! test
if: ${{ startsWith(matrix.scala, '3.') && matrix.platform == 'JVM' }}
run: sbt "++${{ matrix.scala }} test"

publish:
runs-on: ubuntu-20.04
Expand Down
17 changes: 10 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ val zioVersion = "2.0.15"
lazy val root = project
.in(file("."))
.settings(
skip / publish := true,
unusedCompileDependenciesFilter -= moduleFilter("org.scala-js", "scalajs-library")
publish / skip := true,
unusedCompileDependenciesFilter -= moduleFilter("org.scala-js", "scalajs-library"),
crossScalaVersions := Nil
)
.aggregate(
zioCliJVM,
zioCliJS,
examplesJVM,
examplesJS,
docs
docs,
sbtZioCli
)

lazy val zioCli = crossProject(JSPlatform, JVMPlatform)
Expand Down Expand Up @@ -106,10 +108,11 @@ lazy val docs = project
lazy val sbtZioCli = project
.in(file("sbt-zio-cli"))
.settings(
name := "sbt-zio-cli",
organization := "zio.cli.sbt",
scalaVersion := "2.12.17",
version := "0.0.0-SNAPSHOT",
name := "sbt-zio-cli",
organization := "zio.cli.sbt",
scalaVersion := Scala212,
crossScalaVersions := Seq(Scala212),
version := "0.0.0-SNAPSHOT",
addSbtPlugin("org.scalameta" %% "sbt-native-image" % "0.3.2")
)
.enablePlugins(SbtPlugin)
Expand Down
6 changes: 3 additions & 3 deletions project/BuildHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import scalafix.sbt.ScalafixPlugin.autoImport._

object BuildHelper {

private val Scala212 = "2.12.17"
private val Scala213 = "2.13.10"
val Scala3 = "3.3.0"
val Scala212 = "2.12.17"
val Scala213 = "2.13.10"
val Scala3 = "3.3.0"

val SilencerVersion = "1.17.13"

Expand Down
13 changes: 5 additions & 8 deletions sbt-zio-cli/src/main/scala/zio/cli/sbt/ZIOCLIPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@ object ZIOCLIPlugin extends AutoPlugin with ZIOCLIPluginKeys {
override def requires = NativeImagePlugin

override def projectSettings: Seq[Def.Setting[_]] = Seq(
zioCliNativeImageReady := {
() => {
println("ZIO CLI App Native Image Ready!")
}
zioCliNativeImageReady := { () =>
println("ZIO CLI App Native Image Ready!")
},
zioCliNativeImageOptions := List(
"--allow-incomplete-classpath",
"--report-unsupported-elements-at-runtime",
"--initialize-at-build-time",
"--no-fallback",
"--no-fallback"
),
zioCliMainClass := None,
requires.autoImport.nativeImageReady := zioCliNativeImageReady.value,
zioCliMainClass := None,
requires.autoImport.nativeImageReady := zioCliNativeImageReady.value,
requires.autoImport.nativeImageOptions := zioCliNativeImageOptions.value,
zioCliBuildNative := {
Compile / mainClass := {
Expand All @@ -36,7 +34,6 @@ object ZIOCLIPlugin extends AutoPlugin with ZIOCLIPluginKeys {
zioCliGenerateZshCompletion := {
println("TODO: Not Implemented!")
}

)

}
13 changes: 8 additions & 5 deletions sbt-zio-cli/src/main/scala/zio/cli/sbt/ZIOCLIPluginKeys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import sbt._
trait ZIOCLIPluginKeys {

lazy val zioCliMainClass = settingKey[Option[String]]("The mainClass of the CLI App in the Compile scope")
lazy val zioCliNativeImageOptions = settingKey[Seq[String]]("A collection of arguments to pass the native-image builder to customize native image generation")
lazy val zioCliNativeImageReady = settingKey[() => Unit]("A side-effecting callback that is called the native image is ready.")
lazy val zioCliNativeImageOptions = settingKey[Seq[String]](
"A collection of arguments to pass the native-image builder to customize native image generation"
)
lazy val zioCliNativeImageReady =
settingKey[() => Unit]("A side-effecting callback that is called the native image is ready.")

lazy val zioCliBuildNative = taskKey[Unit]("Build a native image version of the CLI App")
lazy val zioCliBuildNative = taskKey[Unit]("Build a native image version of the CLI App")
lazy val zioCliGenerateBashCompletion = taskKey[Unit]("Generate bash completion for the CLI App")
lazy val zioCliGenerateZshCompletion = taskKey[Unit]("Generate zsh completion for the CLI App")
lazy val zioCliInstallCli = taskKey[Unit]("Run the universal installer")
lazy val zioCliGenerateZshCompletion = taskKey[Unit]("Generate zsh completion for the CLI App")
lazy val zioCliInstallCli = taskKey[Unit]("Run the universal installer")

}

0 comments on commit 5118158

Please sign in to comment.