Skip to content

Commit

Permalink
Cleanup sbt/project settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Ondřej Pelech committed May 19, 2022
1 parent d07215b commit e0498d1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 72 deletions.
95 changes: 23 additions & 72 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ lazy val cldrApiVersion = "3.1.0"

Global / onChangedBuildSource := ReloadOnSourceChanges

resolvers in Global += Resolver.sonatypeRepo("public")

lazy val scalaVersion213 = "2.13.8"
lazy val scalaVersion3 = "3.1.2"
ThisBuild / scalaVersion := scalaVersion213
Expand Down Expand Up @@ -50,7 +48,6 @@ ThisBuild / githubWorkflowBuildMatrixExclusions ++= List(
ThisBuild / Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat

val commonSettings: Seq[Setting[_]] = Seq(
organization := "io.github.cquiroz",
scalacOptions ~= (_.filterNot(
Set(
"-Wdead-code",
Expand All @@ -61,16 +58,7 @@ val commonSettings: Seq[Setting[_]] = Seq(
"-Ywarn-value-discard"
)
)),
Compile / doc / scalacOptions := Seq(),
// Compile / doc / sources := { if (isDotty.value) Seq() else (Compile / doc / sources).value },
Compile / unmanagedSourceDirectories ++= scalaVersionSpecificFolders("main",
baseDirectory.value,
scalaVersion.value
),
Test / unmanagedSourceDirectories ++= scalaVersionSpecificFolders("test",
baseDirectory.value,
scalaVersion.value
)
Compile / doc / scalacOptions := Seq()
)

inThisBuild(
Expand All @@ -88,36 +76,15 @@ inThisBuild(
Developer("alonsodomin", "A. Alonso Dominguez", "", url("https://github.com/alonsodomin")),
Developer("mkotsbak", "Marius B. Kotsbak", "", url("https://github.com/mkotsbak")),
Developer("TimothyKlim", "Timothy Klim", "", url("https://github.com/TimothyKlim"))
),
scmInfo := Some(
ScmInfo(
url("https://github.com/cquiroz/scala-java-locales"),
"scm:git:[email protected]:cquiroz/scala-java-locales.git"
)
)
)
)

def scalaVersionSpecificFolders(srcName: String, srcBaseDir: java.io.File, scalaVersion: String) = {
def extraDirs(suffix: String) =
List(CrossType.Pure, CrossType.Full)
.flatMap(_.sharedSrcDir(srcBaseDir, srcName).toList.map(f => file(f.getPath + suffix)))
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, y)) => extraDirs("-2.x") ++ (if (y >= 13) extraDirs("-2.13+") else Nil)
case Some((0 | 3, _)) => extraDirs("-2.13+") ++ extraDirs("-3.x")
case _ => Nil
}
}

lazy val scalajs_locales: Project = project
lazy val root: Project = project
.in(file("."))
.settings(commonSettings: _*)
.settings(commonSettings)
.settings(
name := "locales",
publish := {},
publishLocal := {},
publishArtifact := false,
crossScalaVersions := Nil
publish / skip := true
)
.aggregate(
core.js,
Expand All @@ -137,19 +104,10 @@ lazy val scalajs_locales: Project = project
demo.native
)

def isScala3 = Def.task {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) =>
true
case _ =>
false
}
}

lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Full)
.in(file("core"))
.settings(commonSettings: _*)
.settings(commonSettings)
.settings(
name := "scala-java-locales",
libraryDependencies ++= Seq(
Expand All @@ -164,11 +122,12 @@ lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform)
)
.jsSettings(
scalacOptions ++= {
if (isScala3.value) Seq("-scalajs-genStaticForwardersForNonTopLevelObjects")
if (scalaVersion.value == scalaVersion3)
Seq("-scalajs-genStaticForwardersForNonTopLevelObjects")
else Seq("-P:scalajs:genStaticForwardersForNonTopLevelObjects")
},
scalacOptions ++= {
if (isScala3.value) Seq.empty
if (scalaVersion.value == scalaVersion3) Seq.empty
else {
val tagOrHash =
if (isSnapshot.value) sys.process.Process("git rev-parse HEAD").lineStream_!.head
Expand All @@ -187,7 +146,7 @@ lazy val cldrDbVersion = "36.0"

lazy val localesFullCurrenciesDb = project
.in(file("localesFullCurrenciesDb"))
.settings(commonSettings: _*)
.settings(commonSettings)
.configure(_.enablePlugins(LocalesPlugin))
.configure(_.enablePlugins(ScalaJSPlugin))
.settings(
Expand All @@ -207,7 +166,7 @@ lazy val localesFullCurrenciesDb = project
lazy val localesFullDb = crossProject(JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("localesFullDb"))
.settings(commonSettings: _*)
.settings(commonSettings)
.configure(_.enablePlugins(LocalesPlugin))
.settings(
name := "locales-full-db",
Expand All @@ -225,7 +184,7 @@ lazy val localesFullDb = crossProject(JSPlatform, NativePlatform)

lazy val localesMinimalEnDb = crossProject(JSPlatform, NativePlatform)
.in(file("localesMinimalEnDb"))
.settings(commonSettings: _*)
.settings(commonSettings)
.configure(_.enablePlugins(LocalesPlugin))
.settings(
name := "locales-minimal-en-db",
Expand All @@ -243,7 +202,7 @@ lazy val localesMinimalEnDb = crossProject(JSPlatform, NativePlatform)

lazy val localesMinimalEnUSDb = crossProject(JSPlatform, NativePlatform)
.in(file("localesMinimalEnUSDb"))
.settings(commonSettings: _*)
.settings(commonSettings)
.configure(_.enablePlugins(LocalesPlugin))
.settings(
name := "locales-minimal-en_US-db",
Expand All @@ -261,12 +220,10 @@ lazy val localesMinimalEnUSDb = crossProject(JSPlatform, NativePlatform)

lazy val testSuite = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.in(file("testSuite"))
.settings(commonSettings: _*)
.settings(commonSettings)
.settings(
publish := {},
publishLocal := {},
publishArtifact := false,
name := "scala-java-locales test",
publish / skip := true,
name := "test",
libraryDependencies += "org.scalameta" %%% "munit" % "1.0.0-M4" % Test,
testFrameworks += new TestFramework("munit.Framework"),
scalacOptions ~= (_.filterNot(
Expand All @@ -277,7 +234,6 @@ lazy val testSuite = crossProject(JVMPlatform, JSPlatform, NativePlatform)
))
)
.jsSettings(Test / parallelExecution := false,
name := "scala-java-locales testSuite on JS",
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule))
)
.jsConfigure(_.dependsOn(core.js, macroUtils, localesFullCurrenciesDb))
Expand All @@ -293,7 +249,6 @@ lazy val testSuite = crossProject(JVMPlatform, JSPlatform, NativePlatform)
"-Dfile.encoding=UTF8",
"-Xmx6G"
),
name := "scala-java-locales testSuite on JVM",
libraryDependencies += "io.github.cquiroz" %%% "cldr-api" % cldrApiVersion
)
.jvmConfigure(_.dependsOn(macroUtils))
Expand All @@ -318,30 +273,26 @@ lazy val macroUtils = project
.settings(
name := "macroutils",
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) =>
Seq.empty
case _ =>
Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value)
}
if (scalaVersion.value == scalaVersion3) Seq.empty
else Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value)
},
scalacOptions ~= (_.filterNot(
Set(
"-deprecation",
"-Xfatal-warnings"
)
)),
Compile / doc / sources := { if (isScala3.value) Seq() else (Compile / doc / sources).value }
Compile / doc / sources := {
if (scalaVersion.value == scalaVersion3) Seq() else (Compile / doc / sources).value
}
)

lazy val demo = crossProject(JSPlatform, NativePlatform)
.in(file("demo"))
.settings(commonSettings: _*)
.settings(commonSettings)
.settings(
publish := {},
publishLocal := {},
publishArtifact := false,
publish / skip := true,
scalaJSUseMainModuleInitializer := true,
name := "scala-java-locales demo"
name := "demo"
)
.dependsOn(core)
File renamed without changes.

0 comments on commit e0498d1

Please sign in to comment.