Skip to content

Commit

Permalink
Scalafmt: update version, configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Nov 28, 2024
1 parent be8e7ed commit aada5e9
Show file tree
Hide file tree
Showing 94 changed files with 2,066 additions and 2,901 deletions.
46 changes: 44 additions & 2 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,54 @@
version = "3.8.3"
version=3.8.4-RC3
assumeStandardLibraryStripMargin = true

align.preset = none
align.stripMargin = true

project.layout = StandardConvention
project.git = true
newlines.inInterpolation = avoid

runner.dialect = scala213
fileOverride {
"glob:**/scala-3*/**" {
runner.dialect = scala3
}
}

optIn.selfAnnotationNewline = false

newlines {
inInterpolation = avoid
avoidForSimpleOverflow = all
ignoreInSyntax = false
source = fold
}
rewrite {
rules = [
AvoidInfix,
Imports,
RedundantBraces,
RedundantParens,
SortModifiers,
]
imports {
expand = true
sort = ascii
groups = [
["metaconfig\\..*"],
["sbt\\..*"],
["java.?\\..*"],
["scala\\..*"],
["org\\..*"],
["com\\..*"],
]
}
redundantBraces {
preset = all
}
redundantParens {
preset = all
}
sortModifiers.preset = styleGuide
trailingCommas.style = "always"
}
onTestFailure = "To fix this, run ./scalafmt from the project root directory"
220 changes: 94 additions & 126 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import java.util.Date
import sbtcrossproject.CrossPlugin.autoImport.crossProject

import com.typesafe.tools.mima.core._

import sbtcrossproject.CrossPlugin.autoImport.crossProject

lazy val V = new {
def munit = "1.0.0"
def scalacheck = "1.18.1"
Expand All @@ -13,40 +15,37 @@ val scala213 = "2.13.15"
val scala3 = "3.3.4"

val ScalaVersions = List(scala213, scala212, scala3)
inThisBuild(
List(
useSuperShell := false,
organization := "org.scalameta",
version ~= { old => old.replace('+', '-') },
licenses := Seq(
"Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")
),
homepage := Some(url("https://github.com/scalameta/metaconfig")),
autoAPIMappings := true,
apiURL := Some(url("https://github.com/scalameta/metaconfig")),
developers += Developer(
"olafurpg",
"Ólafur Páll Geirsson",
"olafurpg@gmail.com",
url("https://geirsson.com")
),
resolvers ++= Resolver.sonatypeOssRepos("snapshots"),
versionScheme := Some("early-semver")
)
)
inThisBuild(List(
useSuperShell := false,
organization := "org.scalameta",
version ~= { old => old.replace('+', '-') },
licenses :=
Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
homepage := Some(url("https://github.com/scalameta/metaconfig")),
autoAPIMappings := true,
apiURL := Some(url("https://github.com/scalameta/metaconfig")),
developers += Developer(
"olafurpg",
"Ólafur Páll Geirsson",
"olafurpg@gmail.com",
url("https://geirsson.com"),
),
resolvers ++= Resolver.sonatypeOssRepos("snapshots"),
versionScheme := Some("early-semver"),
))

addCommandAlias(
"scalafixAll",
s"; ++$scala212 ; scalafixEnable ; all scalafix test:scalafix"
s"; ++$scala212 ; scalafixEnable ; all scalafix test:scalafix",
)
addCommandAlias(
"scalafixCheckAll",
s"; ++$scala212 ; scalafixEnable ; scalafix --check ; test:scalafix --check"
s"; ++$scala212 ; scalafixEnable ; scalafix --check ; test:scalafix --check",
)

addCommandAlias(
"native-image",
"; tests/graalvm-native-image:packageBin ; taskready"
"; tests/graalvm-native-image:packageBin ; taskready",
)

commands += Command.command("taskready") { s =>
Expand All @@ -57,8 +56,7 @@ commands += Command.command("taskready") { s =>

lazy val warnUnusedImport = Def.setting {
if (
scalaVersion.value.startsWith("2.13") ||
scalaVersion.value.startsWith("3.")
scalaVersion.value.startsWith("2.13") || scalaVersion.value.startsWith("3.")
) "-Wunused:imports"
else "-Ywarn-unused-import"
}
Expand All @@ -82,128 +80,104 @@ val languageAgnosticCompatibilityPolicy: ProblemFilter = (problem: Problem) => {

lazy val sharedSettings = List[Setting[_]](
scalacOptions ++= yRangePos.value,
scalacOptions ++= Seq(
"-deprecation",
warnUnusedImport.value
),
mimaBinaryIssueFilters ++= List[ProblemFilter](
languageAgnosticCompatibilityPolicy
),
scalacOptions ++= Seq("-deprecation", warnUnusedImport.value),
mimaBinaryIssueFilters ++=
List[ProblemFilter](languageAgnosticCompatibilityPolicy),
crossScalaVersions := ScalaVersions,
scalaVersion := scala213
scalaVersion := scala213,
)

lazy val mimaSettings = List[Setting[_]](
mimaPreviousArtifacts := Set("com.geirsson" %% moduleName.value % "0.9.10")
mimaPreviousArtifacts := Set("com.geirsson" %% moduleName.value % "0.9.10"),
)

publish / skip := true
disablePlugins(MimaPlugin)

lazy val pprint = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.in(file("metaconfig-pprint"))
.settings(
.in(file("metaconfig-pprint")).settings(
sharedSettings,
mimaSettings,
moduleName := "metaconfig-pprint",
libraryDependencies += "com.lihaoyi" %%% "fansi" % "0.5.0",
libraryDependencies ++= {
if (scalaVersion.value.startsWith("2."))
List(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang" % "scala-compiler" % scalaVersion.value
)
if (scalaVersion.value.startsWith("2.")) List(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
)
else Nil
}
},
)

lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.in(file("metaconfig-core"))
.settings(
.in(file("metaconfig-core")).settings(
sharedSettings,
mimaSettings,
moduleName := "metaconfig-core",
libraryDependencies ++= List(
"org.typelevel" %%% "paiges-core" % "0.4.4",
"org.scala-lang.modules" %%% "scala-collection-compat" % "2.12.0"
)
)
.settings(
"org.scala-lang.modules" %%% "scala-collection-compat" % "2.12.0",
),
).settings(
libraryDependencies += {
if (scalaVersion.value.startsWith("3."))
"org.scala-lang" % "scala-reflect" % scala213
if (scalaVersion.value.startsWith("3.")) "org.scala-lang" %
"scala-reflect" % scala213
else "org.scala-lang" % "scala-reflect" % scalaVersion.value
},
Compile / unmanagedSourceDirectories ++= {
// TODO: why isn't sbt-crossproject adding epoch scala version
// sources? it should
if (scalaVersion.value.startsWith("2"))
Seq(
(ThisBuild / baseDirectory).value / "metaconfig-core" / "shared" / "src" / "main" / "scala-2"
)
if (scalaVersion.value.startsWith("2")) Seq(
(ThisBuild / baseDirectory).value / "metaconfig-core" / "shared" /
"src" / "main" / "scala-2",
)
else Seq.empty
}
)
.dependsOn(pprint)
},
).dependsOn(pprint)

lazy val typesafe = project
.in(file("metaconfig-typesafe-config"))
.settings(
sharedSettings,
mimaSettings,
moduleName := "metaconfig-typesafe-config",
description := "Integration for HOCON using typesafehub/config.",
libraryDependencies += "com.typesafe" % "config" % "1.4.3"
)
.dependsOn(core.jvm)
lazy val typesafe = project.in(file("metaconfig-typesafe-config")).settings(
sharedSettings,
mimaSettings,
moduleName := "metaconfig-typesafe-config",
description := "Integration for HOCON using typesafehub/config.",
libraryDependencies += "com.typesafe" % "config" % "1.4.3",
).dependsOn(core.jvm)

lazy val sconfig = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.in(file("metaconfig-sconfig"))
.settings(
.in(file("metaconfig-sconfig")).settings(
sharedSettings,
mimaSettings,
moduleName := "metaconfig-sconfig",
description := "Integration for HOCON using ekrich/sconfig.",
libraryDependencies ++= List(
"org.ekrich" %%% "sconfig" % "1.8.1"
)
)
.platformsSettings(JSPlatform, NativePlatform)(
libraryDependencies ++= List(
"org.ekrich" %%% "sjavatime" % "1.3.0"
)
)
.dependsOn(core)
libraryDependencies ++= List("org.ekrich" %%% "sconfig" % "1.8.1"),
).platformsSettings(JSPlatform, NativePlatform)(
libraryDependencies ++= List("org.ekrich" %%% "sjavatime" % "1.3.0"),
).dependsOn(core)

lazy val tests = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.in(file("metaconfig-tests"))
.disablePlugins(MimaPlugin)
.settings(
.in(file("metaconfig-tests")).disablePlugins(MimaPlugin).settings(
sharedSettings,
publish / skip := true,
Compile / packageDoc / publishArtifact := false,
testFrameworks := List(new TestFramework("munit.Framework")),
libraryDependencies ++= List(
"org.scalacheck" %%% "scalacheck" % V.scalacheck,
"org.scalameta" %%% "munit-scalacheck" % V.munit % Test
)
)
.jsSettings(
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule))
"org.scalameta" %%% "munit-scalacheck" % V.munit % Test,
),
)
.jsSettings(scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)))
.jvmSettings(
GraalVMNativeImage / mainClass := Some("metaconfig.tests.ExampleMain"),
Compile / doc / sources := Seq.empty,
libraryDependencies ++= {
if (scalaVersion.value.startsWith("2."))
Seq(
"com.github.alexarchambault" %%% "scalacheck-shapeless_1.15" % "1.3.0"
)
if (scalaVersion.value.startsWith("2.")) Seq(
"com.github.alexarchambault" %%% "scalacheck-shapeless_1.15" % "1.3.0",
)
else Seq("org.typelevel" %% "shapeless3-deriving" % "3.4.3")
},
graalVMNativeImageOptions ++= {
val reflectionFile =
(Compile / Keys.sourceDirectory).value / "graal" / "reflection.json"
val reflectionFile = (Compile / Keys.sourceDirectory).value / "graal" /
"reflection.json"
assert(reflectionFile.exists, "no such file: " + reflectionFile)
List(
"-H:+ReportUnsupportedElementsAtRuntime",
Expand All @@ -217,36 +191,30 @@ lazy val tests = crossProject(JVMPlatform, JSPlatform, NativePlatform)
"--no-fallback",
s"-H:ReflectionConfigurationFiles=$reflectionFile",
"--allow-incomplete-classpath",
"-H:+ReportExceptionStackTraces"
"-H:+ReportExceptionStackTraces",
)
}
)
.jvmConfigure(
_.enablePlugins(GraalVMNativeImagePlugin)
.dependsOn(typesafe, sconfig.jvm)
)
.dependsOn(core)

lazy val docs = project
.in(file("metaconfig-docs"))
.settings(
sharedSettings,
libraryDependencies ++= List(
"com.lihaoyi" %%% "scalatags" % "0.13.1",
"org.scalacheck" %%% "scalacheck" % V.scalacheck,
"org.scalameta" %%% "munit-scalacheck" % V.munit % Test
),
publish / skip := true,
moduleName := "metaconfig-docs",
mdocVariables := Map(
"VERSION" -> version.value.replaceFirst("\\+.*", ""),
"SCALA_VERSION" -> scalaVersion.value
),
mdocOut := (ThisBuild / baseDirectory).value / "website" / "target" / "docs",
mdocExtraArguments := List("--no-link-hygiene"),
// mdoc's metaconfig might (and will eventually) lag behind the current version, causing eviction errors
evictionErrorLevel := Level.Warn
)
.dependsOn(core.jvm, typesafe, sconfig.jvm)
.enablePlugins(DocusaurusPlugin)
},
).jvmConfigure(_.enablePlugins(GraalVMNativeImagePlugin).dependsOn(
typesafe,
sconfig.jvm,
)).dependsOn(core)

lazy val docs = project.in(file("metaconfig-docs")).settings(
sharedSettings,
libraryDependencies ++= List(
"com.lihaoyi" %%% "scalatags" % "0.13.1",
"org.scalacheck" %%% "scalacheck" % V.scalacheck,
"org.scalameta" %%% "munit-scalacheck" % V.munit % Test,
),
publish / skip := true,
moduleName := "metaconfig-docs",
mdocVariables := Map(
"VERSION" -> version.value.replaceFirst("\\+.*", ""),
"SCALA_VERSION" -> scalaVersion.value,
),
mdocOut := (ThisBuild / baseDirectory).value / "website" / "target" / "docs",
mdocExtraArguments := List("--no-link-hygiene"),
// mdoc's metaconfig might (and will eventually) lag behind the current version, causing eviction errors
evictionErrorLevel := Level.Warn,
).dependsOn(core.jvm, typesafe, sconfig.jvm).enablePlugins(DocusaurusPlugin)
.disablePlugins(MimaPlugin)
Loading

0 comments on commit aada5e9

Please sign in to comment.