Skip to content

Commit

Permalink
Fix sbt warnings and add scalafix
Browse files Browse the repository at this point in the history
  • Loading branch information
eikek committed Apr 12, 2021
1 parent b83e655 commit b5085f7
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 12 deletions.
13 changes: 13 additions & 0 deletions .scalafix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
rules = [
ProcedureSyntax
OrganizeImports
]
OrganizeImports {
coalesceToWildcardImportThreshold = 3
expandRelative = true
groupedImports = Keep
importsOrder = Ascii
groups = ["re:javax?\\.", "scala.", "re:(cats|fs2)\\.", "sharry.", "*"]
importSelectorsOrder = Ascii
removeUnused = true
}
35 changes: 24 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import com.typesafe.sbt.SbtGit.GitKeys._

val elmCompileMode = settingKey[ElmCompileMode]("How to compile elm sources")

val scalafixSettings = Seq(
semanticdbEnabled := true, // enable SemanticDB
semanticdbVersion := scalafixSemanticdb.revision, //"4.4.0"
ThisBuild / scalafixDependencies ++= Dependencies.organizeImports
)

val sharedSettings = Seq(
organization := "com.github.eikek",
scalaVersion := "2.13.5",
Expand All @@ -22,8 +28,8 @@ val sharedSettings = Seq(
"-Wvalue-discard",
"-Wnumeric-widen"
),
scalacOptions in (Compile, console) := Seq()
)
Compile / console / scalacOptions := Seq()
) ++ scalafixSettings

val testSettings = Seq(
testFrameworks += new TestFramework("minitest.runner.Framework"),
Expand Down Expand Up @@ -52,7 +58,7 @@ val elmSettings = Seq(
val webjarSettings = Seq(
Compile / resourceGenerators += Def.task {
copyWebjarResources(
Seq((sourceDirectory in Compile).value / "webjar"),
Seq((Compile/sourceDirectory).value / "webjar"),
(Compile / resourceManaged).value,
name.value,
version.value,
Expand All @@ -70,7 +76,7 @@ val debianSettings = Seq(
maintainer := "Eike Kettner <[email protected]>",
packageSummary := description.value,
packageDescription := description.value,
mappings in Universal += {
Universal/mappings += {
val conf = (Compile / resourceDirectory).value / "reference.conf"
if (!conf.exists)
sys.error(s"File $conf not found")
Expand Down Expand Up @@ -231,7 +237,7 @@ val restserver = project
addCompilerPlugin(Dependencies.kindProjectorPlugin),
addCompilerPlugin(Dependencies.betterMonadicFor),
buildInfoPackage := "sharry.restserver",
javaOptions in reStart ++=
reStart / javaOptions ++=
Seq(
s"-Dconfig.file=${(LocalRootProject / baseDirectory).value / "local" / "dev.conf"}",
"-Dsharry.migrate-old-dbschema=false",
Expand Down Expand Up @@ -263,7 +269,7 @@ lazy val microsite = project
.settings(
name := "sharry-microsite",
publishArtifact := false,
skip in publish := true,
publish /skip := true,
micrositeFooterText := Some(
"""
|<p>&copy; 2020 <a href="https://eikek.github.io/sharry">Sharry, v{{site.version}}</a></p>
Expand All @@ -284,19 +290,19 @@ lazy val microsite = project
"brand-secondary" -> "#009ADA",
"white-color" -> "#FFFFFF"
),
fork in run := true,
run /fork := true,
mdocVariables := Map(
"VERSION" -> version.value,
"PVERSION" -> version.value.replace('.', '_')
),
Compile / resourceGenerators += Def.task {
val conf1 = (resourceDirectory in (restserver, Compile)).value / "reference.conf"
val conf1 = (restserver/Compile/resourceDirectory).value / "reference.conf"
val out1 = resourceManaged.value / "main" / "jekyll" / "_includes" / "server.conf"
streams.value.log.info(s"Copying reference.conf: $conf1 -> $out1")
IO.write(out1, "{% raw %}\n")
IO.append(out1, IO.readBytes(conf1))
IO.write(out1, "\n{% endraw %}", append = true)
val oa1 = (resourceDirectory in (restapi, Compile)).value / "sharry-openapi.yml"
val oa1 = (restapi / Compile /resourceDirectory).value / "sharry-openapi.yml"
val oaout =
resourceManaged.value / "main" / "jekyll" / "openapi" / "sharry-openapi.yml"
IO.copy(Seq(oa1 -> oaout))
Expand Down Expand Up @@ -392,6 +398,13 @@ addCommandAlias(
"make",
";set webapp/elmCompileMode := ElmCompileMode.Production ;root/openapiCodegen ;root/test:compile"
)
addCommandAlias("make-zip", ";restserver/universal:packageBin")
addCommandAlias("make-deb", ";restserver/debian:packageBin")
addCommandAlias("make-zip", ";restserver/Universal/packageBin")
addCommandAlias("make-deb", ";restserver/Debian/packageBin")
addCommandAlias("make-pkg", ";clean ;make ;make-zip ;make-deb")

addCommandAlias("ci", "make; lint; test")
addCommandAlias(
"lint",
"scalafmtSbtCheck; scalafmtCheckAll; Compile/scalafix --check; Test/scalafix --check"
)
addCommandAlias("fix", "Compile/scalafix; Test/scalafix; scalafmtSbt; scalafmtAll")
5 changes: 5 additions & 0 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ object Dependencies {
val LogbackVersion = "1.2.3"
val MariaDbVersion = "2.7.2"
val MiniTestVersion = "2.9.4"
val OrganizeImportsVersion = "0.5.0"
val PostgresVersion = "42.2.19"
val PureConfigVersion = "0.14.1"
val SwaggerVersion = "3.46.0"
Expand Down Expand Up @@ -129,4 +130,8 @@ object Dependencies {
"org.webjars" % "clipboard.js" % ClipboardJsVersion
)

val organizeImports = Seq(
"com.github.liancheng" %% "organize-imports" % OrganizeImportsVersion
)

}
1 change: 1 addition & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.27")
addSbtPlugin("com.47deg" % "sbt-microsites" % "1.3.3")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
addSbtPlugin("com.github.eikek" % "sbt-openapi-schema" % "0.7.1")
Expand Down
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "1.7.0-SNAPSHOT"
ThisBuild / version := "1.7.0-SNAPSHOT"

0 comments on commit b5085f7

Please sign in to comment.