From 58816e88b344e4133197f465af75861ce42d292d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Hern=C3=A1ndez?= Date: Mon, 13 Apr 2020 18:57:23 +0200 Subject: [PATCH] Simplify SBT build and fix docs generation (#456) * These settings aren't needed anymore They're automatically provided by `sbt-github` * Remove unused method * This is the new way of preventing module publishing * Use new `project` macro for creating new projects This macro will use the `val` name as the expected folder and `moduleName` * We need to add `mdocIn` for project docs * Not needed (already provided by `sbt-github-mdoc`) * The root module is auto-created by SBT, only need to skip publishing * Launch scalafmtSbt --- build.sbt | 39 +++++++++++++++---------------------- project/ProjectPlugin.scala | 19 ------------------ 2 files changed, 16 insertions(+), 42 deletions(-) diff --git a/build.sbt b/build.sbt index 80a0c4435..f85246425 100644 --- a/build.sbt +++ b/build.sbt @@ -1,43 +1,36 @@ addCommandAlias("ci-test", "+scalafmtCheck; +scalafmtSbtCheck; +docs/mdoc; +test") addCommandAlias("ci-docs", "project-docs/mdoc; headerCreateAll") -lazy val root = (project in file(".")) - .settings(moduleName := "github4s-root") - .aggregate(github4s) - .dependsOn(github4s) - .settings(noPublishSettings: _*) +skip in publish := true -lazy val github4s = - (project in file("github4s")) - .settings(moduleName := "github4s") - .enablePlugins(BuildInfoPlugin) - .settings( - buildInfoKeys := Seq[BuildInfoKey]( - name, - version, - "token" -> sys.env.getOrElse("GITHUB_TOKEN", "") - ), - buildInfoPackage := "github4s" - ) - .settings(coreDeps: _*) +lazy val github4s = project + .enablePlugins(BuildInfoPlugin) + .settings( + buildInfoKeys := Seq[BuildInfoKey]( + name, + version, + "token" -> sys.env.getOrElse("GITHUB_TOKEN", "") + ), + buildInfoPackage := "github4s" + ) + .settings(coreDeps: _*) ////////// // DOCS // ////////// -lazy val docs = (project in file("docs")) +lazy val docs = project .aggregate(github4s) .dependsOn(github4s) - .settings(moduleName := "github4s-docs") .settings(micrositeSettings: _*) - .settings(noPublishSettings: _*) + .settings(skip in publish := true) .enablePlugins(MicrositesPlugin) lazy val `project-docs` = (project in file(".docs")) .aggregate(github4s) .dependsOn(github4s) .settings(moduleName := "github4s-project-docs") - .settings(mdocVariables += "NAME" -> "github4s") + .settings(mdocIn := file(".docs")) .settings(mdocOut := file(".")) - .settings(noPublishSettings: _*) + .settings(skip in publish := true) .enablePlugins(MdocPlugin) diff --git a/project/ProjectPlugin.scala b/project/ProjectPlugin.scala index 4769ce971..dffa92bb0 100644 --- a/project/ProjectPlugin.scala +++ b/project/ProjectPlugin.scala @@ -30,13 +30,6 @@ object ProjectPlugin extends AutoPlugin { val silencer: String = "1.6.0" } - lazy val noPublishSettings = Seq( - publish := ((): Unit), - publishLocal := ((): Unit), - publishArtifact := false, - publishMavenStyle := false // suppress warnings about intransitive deps (not published anyway) - ) - lazy val micrositeSettings = Seq( micrositeName := "Github4s", micrositeDescription := "Github API wrapper written in Scala", @@ -92,25 +85,13 @@ object ProjectPlugin extends AutoPlugin { }) ) - def toCompileTestList(sequence: Seq[ProjectReference]): List[String] = sequence.toList.map { - p => - val project: String = p.asInstanceOf[LocalProject].project - s"$project/test" - } } import autoImport.V override def projectSettings: Seq[Def.Setting[_]] = Seq( - name := "github4s", organization := "com.47deg", - organizationName := "47 Degrees", - organizationHomepage := Some(url("https://www.47deg.com")), - homepage := Option(url("https://47degrees.github.io/github4s/")), - description := "Github API wrapper written in Scala", - startYear := Option(2016), - resolvers += Resolver.sonatypeRepo("snapshots"), crossScalaVersions := Seq(V.scala212, V.scala213), scalacOptions := { val withStripedLinter = scalacOptions.value filterNot Set("-Xlint", "-Xfuture").contains