Skip to content

Commit

Permalink
Update build & tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cchantep committed Sep 6, 2022
1 parent d7d07ac commit 9dc1974
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 251 deletions.
139 changes: 64 additions & 75 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ lazy val scala_2_13 = Project(id = "scala_2_13", base = file("scala_2_13"))
publishArtifact := false,
publishLocal := {},
// doctestWithDependencies := false, // sbt-doctest is not yet compatible with this 2.13
aggregate in publish := false,
aggregate in PgpKeys.publishSigned := false
publish / aggregate := false,
PgpKeys.publishSigned / aggregate := false
)
.aggregate((baseProjectRefs ++ scala213ProjectRefs): _*)

Expand All @@ -134,7 +134,7 @@ lazy val scala211ProjectRefs = Seq(
enumeratumJson4s,
enumeratumScalacheckJvm,
enumeratumScalacheckJs,
enumeratumPlayJsonJvm,
// enumeratumPlayJsonJvm,
// TODO drop 2.11 as play-json 2.7.x supporting Scala.js 1.x is unlikely?
// enumeratumPlayJsonJs, TODO re-enable once play-json supports Scala.js 1.0
enumeratumArgonautJs,
Expand All @@ -159,8 +159,8 @@ lazy val scala_2_11 = Project(id = "scala_2_11", base = file("scala_2_11"))
publishArtifact := false,
publishLocal := {},
// doctestWithDependencies := false, // sbt-doctest is not yet compatible with this 2.13
aggregate in publish := false,
aggregate in PgpKeys.publishSigned := false
publish / aggregate := false,
PgpKeys.publishSigned / aggregate := false
)
.aggregate((baseProjectRefs ++ scala211ProjectRefs): _*)

Expand All @@ -186,17 +186,17 @@ lazy val integrationProjectRefs = Seq(

lazy val root =
Project(id = "enumeratum-root", base = file("."))
.settings(commonWithPublishSettings: _*)
.settings(commonWithPublishSettings)
.settings(
name := "enumeratum-root",
crossVersion := CrossVersion.binary,
crossScalaVersions := Nil,
git.gitRemoteRepo := "[email protected]:lloydmeta/enumeratum.git",
// Do not publish the root project (it just serves as an aggregate)
publishArtifact := false,
publishLocal := {},
aggregate in publish := false,
aggregate in PgpKeys.publishSigned := false
publishArtifact := false,
publishLocal := {},
publish / aggregate := false,
PgpKeys.publishSigned / aggregate := false
)
.aggregate(baseProjectRefs ++ integrationProjectRefs: _*)

Expand All @@ -212,13 +212,11 @@ lazy val macros = crossProject(JSPlatform, JVMPlatform)
name := "enumeratum-macros",
version := Versions.Macros.head,
crossScalaVersions := scalaVersionsAll, // eventually move this to aggregateProject once more 2.13 libs are out
libraryDependencies ++= {
if (scalaBinaryVersion.value startsWith "2.") {
Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value)
libraryDependencies += {
if (scalaBinaryVersion.value == "3") {
"org.scala-lang" %% "scala3-compiler" % scalaVersion.value % Provided
} else {
Seq(
"org.scala-lang" %% "scala3-compiler" % scalaVersion.value % Provided
)
"org.scala-lang" % "scala-reflect" % scalaVersion.value
}
}
)
Expand Down Expand Up @@ -249,42 +247,33 @@ lazy val core = crossProject(JSPlatform, JVMPlatform)
}
)

def configureWithLocal(m: Project): Project => Project = { p =>
def configureWithLocal(
dep: (Project, Option[String]),
deps: List[(Project, Option[String])] = Nil
): Project => Project = {
if (useLocalVersion) { // used for testing macros
p.dependsOn(m)
{ (prj: Project) =>
(dep :: deps).foldLeft(prj) {
case (p, (m, Some(x))) =>
p.dependsOn(m % x)

case (p, (m, None)) =>
p.dependsOn(m)
}
}
} else {
p
identity[Project]
}
}

lazy val coreJS = core.js.configure(configureWithLocal(macrosJS))
lazy val coreJVM = core.jvm.configure(configureWithLocal(macrosJVM))

lazy val testsAggregate = aggregateProject("test", enumeratumTestJs, enumeratumTestJvm)

// Project models used in test for some subprojects
lazy val enumeratumTest = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.in(file("enumeratum-test"))
.settings(testSettings)
.jsSettings(jsTestSettings)
.settings(commonWithPublishSettings)
.settings(
name := "enumeratum-test",
version := Versions.Core.stable,
crossScalaVersions := scalaVersionsAll,
libraryDependencies ++= {
if (useLocalVersion) {
Seq.empty
} else {
Seq("com.beachape" %%% "enumeratum" % Versions.Core.stable)
}
}
)
def configureWithLocal(m: Project): Project => Project =
configureWithLocal(m -> Option.empty[String])

lazy val enumeratumTestJs = enumeratumTest.js.configure(configureWithLocal(coreJS))
def configureWithLocal(m: Project, x: String): Project => Project =
configureWithLocal(m -> Some(x))

lazy val enumeratumTestJvm = enumeratumTest.jvm.configure(configureWithLocal(coreJVM))
lazy val coreJS = core.js.configure(configureWithLocal(macrosJS))
lazy val coreJVM = core.jvm.configure(configureWithLocal(macrosJVM))

lazy val coreJVMTests = Project(id = "coreJVMTests", base = file("enumeratum-core-jvm-tests"))
.enablePlugins(BuildInfoPlugin)
Expand All @@ -295,7 +284,7 @@ lazy val coreJVMTests = Project(id = "coreJVMTests", base = file("enumeratum-cor
scalaVersion,
sbtVersion,
BuildInfoKey.action("macrosJVMClassesDir") {
((macrosJVM / classDirectory) in Compile).value
(macrosJVM / Compile / classDirectory).value
}
),
buildInfoPackage := "enumeratum"
Expand Down Expand Up @@ -340,7 +329,7 @@ lazy val enumeratumReactiveMongoBson =
}
}
)
.configure(configureWithLocal(enumeratumTestJvm))
.configure(configureWithLocal(coreJVM, "compile->compile;test->test"))

lazy val playJsonAggregate =
aggregateProject("play-json", enumeratumPlayJsonJs, enumeratumPlayJsonJvm)
Expand Down Expand Up @@ -371,10 +360,10 @@ lazy val enumeratumPlayJson = crossProject(JSPlatform, JVMPlatform)
)

lazy val enumeratumPlayJsonJs = enumeratumPlayJson.js
.configure(configureWithLocal(enumeratumTestJs))
.configure(configureWithLocal(coreJS, "compile->compile;test->test"))

lazy val enumeratumPlayJsonJvm = enumeratumPlayJson.jvm
.configure(configureWithLocal(enumeratumTestJvm))
.configure(configureWithLocal(coreJVM, "compile->compile;test->test"))

lazy val enumeratumPlay = Project(id = "enumeratum-play", base = file("enumeratum-play"))
.settings(commonWithPublishSettings)
Expand All @@ -398,7 +387,7 @@ lazy val enumeratumPlay = Project(id = "enumeratum-play", base = file("enumeratu
}
)
.settings(withCompatUnmanagedSources(jsJvmCrossProject = false, includeTestSrcs = true))
.configure(configureWithLocal(enumeratumTestJvm))
.configure(configureWithLocal(coreJVM, "compile->compile;test->test"))
.dependsOn(enumeratumPlayJsonJvm % "compile->compile;test->test")

lazy val circeAggregate = aggregateProject("circe", enumeratumCirceJs, enumeratumCirceJvm)
Expand Down Expand Up @@ -431,10 +420,10 @@ lazy val enumeratumCirce = crossProject(JSPlatform, JVMPlatform)
)

lazy val enumeratumCirceJs = enumeratumCirce.js
.configure(configureWithLocal(enumeratumTestJs))
.configure(configureWithLocal(coreJS, "compile->compile;test->test"))

lazy val enumeratumCirceJvm = enumeratumCirce.jvm
.configure(configureWithLocal(enumeratumTestJvm))
.configure(configureWithLocal(coreJVM, "compile->compile;test->test"))

lazy val argonautAggregate =
aggregateProject("argonaut", enumeratumArgonautJs, enumeratumArgonautJvm)
Expand Down Expand Up @@ -504,24 +493,26 @@ lazy val enumeratumScalacheck = crossProject(JSPlatform, JVMPlatform)
libraryDependencies ++= {
Seq(
"org.scalacheck" %%% "scalacheck" % theScalacheckVersion(scalaVersion.value),
"org.scalatestplus" %%% "scalacheck-1-14" % "3.1.1.1" % Test,
"com.beachape" %%% "enumeratum-test" % Versions.Core.stable % Test
"org.scalatestplus" %%% "scalacheck-1-14" % "3.1.1.1" % Test
)
},
libraryDependencies ++= {
if (useLocalVersion) {
Seq.empty
} else {
Seq("com.beachape" %%% "enumeratum" % Versions.Core.stable)
Seq(
"com.beachape" %%% "enumeratum" % Versions.Core.stable,
"com.beachape" %%% "enumeratum-test" % Versions.Core.stable % Test
)
}
}
)

lazy val enumeratumScalacheckJs = enumeratumScalacheck.js
.configure(configureWithLocal(coreJS))
.configure(configureWithLocal(coreJS, "compile->compile;test->test"))

lazy val enumeratumScalacheckJvm = enumeratumScalacheck.jvm
.configure(configureWithLocal(coreJVM))
.configure(configureWithLocal(coreJVM, "compile->compile;test->test"))

lazy val quillAggregate =
aggregateProject(
Expand All @@ -532,8 +523,8 @@ lazy val enumeratumQuill =
crossProject(JVMPlatform /*, JSPlatform TODO re-enable once quill supports Scala.js 1.0 */ )
.crossType(CrossType.Pure)
.in(file("enumeratum-quill"))
.settings(commonWithPublishSettings: _*)
.settings(testSettings: _*)
.settings(commonWithPublishSettings)
.settings(testSettings)
// .jsSettings(jsTestSettings: _*) TODO re-enable once quill supports Scala.js 1.0 */,
.settings(
name := "enumeratum-quill",
Expand All @@ -553,9 +544,9 @@ lazy val enumeratumQuill =
}
},
dependencyOverrides ++= {
def pprintVersion(v: String) = {
if (v.startsWith("2.11")) "0.5.4" else "0.5.5"
}
def pprintVersion(v: String) =
if (v startsWith "2.11") "0.5.4" else "0.5.5"

Seq(
"com.lihaoyi" %%% "pprint" % pprintVersion(scalaVersion.value)
)
Expand Down Expand Up @@ -667,17 +658,17 @@ lazy val resolverSettings = Seq(

lazy val ideSettings = Seq(
// Faster "sbt gen-idea"
transitiveClassifiers in Global := Seq(Artifact.SourceClassifier)
Global / transitiveClassifiers := Seq(Artifact.SourceClassifier)
)

lazy val compilerSettings = Seq(
scalaJSStage in ThisBuild := {
ThisBuild / scalaJSStage := {
sys.props.get("sbt.scalajs.testOpt").orElse(sys.env.get("SCALAJS_TEST_OPT")) match {
case Some("full") => FullOptStage
case _ => FastOptStage
}
},
scalacOptions in (Compile, compile) ++= {
Compile / compile / scalacOptions ++= {
val minimal = Seq(
"-encoding",
"UTF-8", // yes, this is 2 args
Expand Down Expand Up @@ -763,21 +754,19 @@ lazy val publishSettings = Seq(
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
pgpPassphrase := sys.env.get("PGP_PASSPHRASE").map(_.toCharArray),
publishMavenStyle := true,
publishArtifact in Test := false,
PgpKeys.pgpPassphrase := sys.env.get("PGP_PASSPHRASE").map(_.toCharArray),
pgpPassphrase := sys.env.get("PGP_PASSPHRASE").map(_.toCharArray),
publishMavenStyle := true,
Test / publishArtifact := false,
PgpKeys.pgpPassphrase := sys.env.get("PGP_PASSPHRASE").map(_.toCharArray),
pomIncludeRepository := { _ =>
false
}
)

val testSettings = {
Seq(
libraryDependencies ++= {
Seq(
"org.scalatest" %%% "scalatest" % scalaTestVersion % Test
)
libraryDependencies += {
"org.scalatest" %%% "scalatest" % scalaTestVersion % Test
},
doctestGenTests := {
val originalValue = doctestGenTests.value
Expand Down Expand Up @@ -838,7 +827,7 @@ def withCompatUnmanagedSources(
}

val unmanagedMainDirsSetting = Seq(
unmanagedSourceDirectories in Compile ++= {
Compile / unmanagedSourceDirectories ++= {
compatDirs(
projectbase = baseDirectory.value,
scalaVersion = scalaVersion.value,
Expand All @@ -848,7 +837,7 @@ def withCompatUnmanagedSources(
)
if (includeTestSrcs) {
unmanagedMainDirsSetting ++ {
unmanagedSourceDirectories in Test ++= {
Test / unmanagedSourceDirectories ++= {
compatDirs(
projectbase = baseDirectory.value,
scalaVersion = scalaVersion.value,
Expand Down
2 changes: 2 additions & 0 deletions enumeratum-core/src/main/scala-2/enumeratum/EnumCompat.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package enumeratum

import scala.collection.immutable.IndexedSeq

import scala.language.experimental.macros

private[enumeratum] trait EnumCompat[A <: EnumEntry] { _: Enum[A] =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package enumeratum.values

import scala.language.experimental.macros

import scala.collection.immutable.IndexedSeq

import _root_.enumeratum.{EnumMacros, ValueEnumMacros}

private[enumeratum] trait IntEnumCompanion {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package enumeratum.values
sealed abstract class Bites(val value: Byte) extends ByteEnumEntry

object Bites extends ByteEnum[Bites] {
val values = findValues
lazy val values = findValues

case object OneByte extends Bites(1)
case object TwoByte extends Bites(2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,5 @@ trait ScalacheckTest {
)
}
}

}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package enumeratum.values

import enumeratum.ScalacheckTest

import org.scalatest.funspec.AnyFunSpec
import org.scalatest.matchers.should.Matchers
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
Expand All @@ -19,5 +20,4 @@ class ScalacheckSpec
test[LongEnumEntry, ContentType]("LongEnumEntry")
test[ShortEnumEntry, Drinks]("ShortEnumEntry")
test[StringEnumEntry, OperatingSystem]("StringEnumEntry")

}
18 changes: 0 additions & 18 deletions enumeratum-test/src/main/scala/enumeratum/values/Alphabet.scala

This file was deleted.

Loading

0 comments on commit 9dc1974

Please sign in to comment.