Skip to content

Commit

Permalink
Added ZIO Ecosystem SBT Plugin (#4)
Browse files Browse the repository at this point in the history
* Added ZIO Ecosystem SBT Plugin

The purpose of this plugin is provide consistent build experience for all projects in the ZIO ecosystem.

This replaces the 'BuildHelper' class that gets copied and pasted from one ZIO project to another.

* Provides standard build syntax for common tasks such as linting, preparing a build, etc.
* Supports extensible custom build commands with helpful descriptions.
* Things like compiler settings, scala versions, etc. are defined in a single place.
* True color ASNI art header!!!

* Fix linting command.

* Formatting

* Remove dead code.

* Removed Sonatype credentials as I assume that we just use the sonatype sbt plugin for publishing.
  • Loading branch information
scottweaver authored Nov 26, 2022
1 parent 08b2082 commit aba0760
Show file tree
Hide file tree
Showing 15 changed files with 774 additions and 296 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Cache scala dependencies
uses: coursier/cache-action@v6
- name: Lint code
run: sbt fmtCheck fixCheck
run: sbt lint

build:
runs-on: ubuntu-20.04
Expand Down
51 changes: 19 additions & 32 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,37 +1,24 @@
version = 2.7.5

align = most
version = "3.0.6"
maxColumn = 120
align.preset = most
align.multiline = false
continuationIndent.defnSite = 2
assumeStandardLibraryStripMargin = true
danglingParentheses = true
docstrings = JavaDoc
docstrings.style = Asterisk
docstrings.wrapMaxColumn = 80
lineEndings = preserve
includeCurlyBraceInSelectChains = false
lineEndings = unix
maxColumn = 120

continuationIndent {
callSite = 2
defnSite = 2
}

newlines {
alwaysBeforeTopLevelStatements = true
alwaysBeforeMultilineDef = true
}

spaces {
afterKeywordBeforeParen = true
inImportCurlyBraces = true
}
danglingParentheses.preset = true
optIn.annotationNewlines = true
newlines.alwaysBeforeMultilineDef = false
runner.dialect = scala213
rewrite.rules = [RedundantBraces]

rewrite.rules = [
AsciiSortImports,
AvoidInfix,
PreferCurlyFors,
RedundantBraces,
RedundantParens,
SortModifiers
]
project.excludePaths = ["glob:**/scalafix/input/**", "glob:**/scalafix/output/**"]

optIn {
annotationNewlines = true
rewrite.redundantBraces.generalExpressions = false
rewriteTokens = {
"⇒": "=>"
"→": "->"
"←": "<-"
}
69 changes: 39 additions & 30 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import sbtcrossproject.CrossPlugin.autoImport.crossProject
import BuildHelper.{ crossProjectSettings, _ }
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport.scalaJSUseMainModuleInitializer

sbtPlugin := true
sbtPlugin := true
publishMavenStyle := true

enablePlugins(ZioEcosystemProjectPlugin)
addCommand(List("scripted"), "testPlugin", "Runs the scripted SBT plugin tests.")

inThisBuild(
List(
name := "zio-sbt",
organization := "dev.zio",
homepage := Some(url("https://github.com/zio/zio-sbt")),
startYear := Some(2022),
homepage := Some(url("https://github.com/zio/zio-sbt")),
developers := List(
Developer(
"khajavi",
Expand All @@ -24,11 +26,6 @@ inThisBuild(
"scm:git:git@github.com:zio/zio-sbt.git"
)
),
licenses := Seq(
"Apache-2.0" -> url(
s"${scmInfo.value.map(_.browseUrl).get}/blob/v${version.value}/LICENSE"
)
),
pgpPassphrase := sys.env.get("PGP_PASSWORD").map(_.toArray),
pgpPublicRing := file("/tmp/public.asc"),
pgpSecretRing := file("/tmp/secret.asc")
Expand All @@ -37,66 +34,78 @@ inThisBuild(

ThisBuild / publishTo := sonatypePublishToBundle.value

addCommandAlias("testPlugin", "scripted; test")
addCommandAlias("prepare", "fix; fmt")
addCommandAlias("fmt", "all scalafmtSbt scalafmtAll")
addCommandAlias("fmtCheck", "all scalafmtSbtCheck scalafmtCheckAll")
addCommandAlias("fix", "scalafixAll")
addCommandAlias("fixCheck", "scalafixAll --check")

lazy val root = project
.in(file("."))
.settings(
name := "zio-sbt",
name := "zio-sbt",
publish / skip := true
)
.aggregate(
zioSbtWebsite,
zioSbtEcosystem,
tests
)

lazy val tests =
project
.in(file("tests"))
.settings(stdSettings("zio-sbt-tests"))
.settings(publish / skip := true)
.settings(Seq(name := "zio-sbt-tests", publish / skip := true))
.settings(buildInfoSettings("zio.sbt"))
.enablePlugins(ZioEcosystemProjectPlugin)

lazy val zioSbtWebsite =
project
.in(file("zio-sbt-website"))
.settings(stdSettings("zio-sbt-website"))
.settings(buildInfoSettings("zio.sbt"))
.settings(addCommand(List("scripted"), "testPlugin", "Runs the scripted SBT plugin tests."))
.settings(
name := "zio-sbt-website",
crossScalaVersions := Seq.empty,
scalaVersion := versions.Scala212,
scriptedLaunchOpts := {
scriptedLaunchOpts.value ++
Seq("-Xmx1024M", "-Dplugin.version=" + version.value)
},
scriptedBufferLog := false
)
.enablePlugins(SbtPlugin)
.enablePlugins(SbtPlugin, ZioEcosystemProjectPlugin)

lazy val zioSbtEcosystem =
project
.in(file("zio-sbt-ecosystem"))
.settings(buildInfoSettings("zio.sbt"))
.settings(addCommand(List("scripted"), "testPlugin", "Runs the scripted SBT plugin tests."))
.settings(
name := "zio-sbt-ecosystem",
crossScalaVersions := Seq.empty,
needsZio := false,
scalaVersion := versions.Scala212,
scriptedLaunchOpts := {
scriptedLaunchOpts.value ++
Seq("-Xmx1024M", "-Dplugin.version=" + version.value)
},
scriptedBufferLog := false
)
.enablePlugins(SbtPlugin, ZioEcosystemProjectPlugin)

lazy val docs = project
.in(file("zio-sbt-docs"))
.settings(
publish / skip := true,
mdocVariables := Map(
"SNAPSHOT_VERSION" -> version.value,
"RELEASE_VERSION" -> previousStableVersion.value.getOrElse(
"RELEASE_VERSION" -> previousStableVersion.value.getOrElse(
"can't find release"
),
"ORG" -> organization.value,
"NAME" -> (root / name).value,
"CROSS_VERSIONS" -> (root / crossScalaVersions).value.mkString(", ")
"ORG" -> organization.value,
"NAME" -> (root / name).value,
"CROSS_VERSIONS" -> (root / crossScalaVersions).value.mkString(", ")
),
moduleName := "zio-sbt-docs",
scalacOptions -= "-Yno-imports",
scalacOptions -= "-Xfatal-warnings",
libraryDependencies ++= Seq(
"dev.zio" %% "zio" % zioVersion
),
ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(root),
ScalaUnidoc / unidoc / target := (LocalRootProject / baseDirectory).value / "website" / "static" / "api",
ScalaUnidoc / unidoc / target := (LocalRootProject / baseDirectory).value / "website" / "static" / "api",
cleanFiles += (ScalaUnidoc / unidoc / target).value,
docusaurusCreateSite := docusaurusCreateSite
.dependsOn(Compile / unidoc)
Expand All @@ -106,4 +115,4 @@ lazy val docs = project
.value
)
.dependsOn(root)
.enablePlugins(MdocPlugin, DocusaurusPlugin, ScalaUnidocPlugin)
.enablePlugins(ZioEcosystemProjectPlugin, MdocPlugin, DocusaurusPlugin, ScalaUnidocPlugin)
Loading

0 comments on commit aba0760

Please # to comment.