Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Scala.js support + update dependencies #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 71 additions & 75 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,83 +2,79 @@ import scalariform.formatter.preferences._
import com.typesafe.sbt.SbtScalariform.{ScalariformKeys, autoImport}

val projectName = "play-json-extensions"
lazy val root = Project(id = projectName, base = file("."))

version := "0.42.0"
organization := "ai.x"
name := projectName
scalaVersion := "2.12.10"
crossScalaVersions := Seq("2.12.10", "2.13.1")
useGpg := true
credentials += Credentials(Path.userHome / ".sbt" / "sonatype_credential")
description := "Additional type classes for the play-json serialization library"
organizationName := "x.ai - Magically schedule meetings"

val ghProject = "xdotai/"+projectName
val ghUrl = url( "https://github.com/" + ghProject )

homepage := Some( ghUrl )
startYear := Some(2015)
licenses += (
"Two-clause BSD-style license",
url( ghUrl + "/blob/master/LICENSE.txt" )
)
scmInfo := Some(
ScmInfo( ghUrl, "[email protected]:" + ghProject + ".git" )
)
developers := List(
Developer("cvogt", "Jan Christopher Vogt", "@cvogt", url("https://github.com/cvogt"))
)

libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % "2.8.1",
"org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided",
"org.scalatest" %% "scalatest" % "3.0.8" % "test"
)
val ghUrl = url("https://github.com/" + ghProject)

resolvers ++= Seq(
Resolver.sonatypeRepo("releases"),
Resolver.sonatypeRepo("snapshots")
val sharedSettings = Seq(
version := "0.43.0-SNAPSHOT",
organization := "ai.x",
name := projectName,
scalaVersion := "2.12.10",
crossScalaVersions := Seq("2.12.10", "2.13.1"),
useGpg := true,
credentials += Credentials(Path.userHome / ".sbt" / "sonatype_credential"),
description := "Additional type classes for the play-json serialization library",
organizationName := "x.ai - Magically schedule meetings",
homepage := Some(ghUrl),
startYear := Some(2015),
licenses += ("Two-clause BSD-style license", url(ghUrl + "/blob/master/LICENSE.txt")),
scmInfo := Some(ScmInfo(ghUrl, "[email protected]:" + ghProject + ".git" )),
developers := List(
Developer("cvogt", "Jan Christopher Vogt", "@cvogt", url("https://github.com/cvogt"))
),
libraryDependencies ++= Seq(
"com.typesafe.play" %%% "play-json" % "2.9.2",
"org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided",
"org.scalatest" %%% "scalatest" % "3.2.12" % "test"
),
resolvers ++= Seq(
Resolver.sonatypeRepo("releases"),
Resolver.sonatypeRepo("snapshots")
),
scalacOptions ++= Seq(
"-feature", "-deprecation", "-unchecked",
"-language:experimental.macros",
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) => "-Ywarn-unused-import"
case _ => "-Ywarn-unused:imports"
},
"-Xfatal-warnings"
),
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oFD"),
parallelExecution := false, // <- until TMap thread-safety issues are resolved
scalacOptions in (Compile, doc) ++= Seq(
"-doc-title", name.value,
"-doc-version", version.value,
"-doc-footer", projectName+" is developed by x.ai.",
"-sourcepath", (sourceDirectory in Compile).value.getPath, // needed for scaladoc to strip the location of the linked source path
"-doc-source-url", ghUrl+"/blob/"+version.value+"/src/main€{FILE_PATH}.scala",
"-implicits",
"-diagrams", // requires graphviz
"-groups"
),
scalariformPreferences := scalariformPreferences.value
.setPreference(AlignParameters, true)
.setPreference(AlignArguments, true)
.setPreference(AlignSingleLineCaseStatements, true)
.setPreference(MultilineScaladocCommentsStartOnFirstLine, true)
.setPreference(SpaceInsideParentheses, true)
.setPreference(SpacesWithinPatternBinders, true)
.setPreference(SpacesAroundMultiImports, true)
.setPreference(DanglingCloseParenthesis, Preserve)
.setPreference(DoubleIndentConstructorArguments, true)
)

scalacOptions ++= Seq(
"-feature", "-deprecation", "-unchecked",
"-language:experimental.macros",
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) => "-Ywarn-unused-import"
case _ => "-Ywarn-unused:imports"
},
"-Xfatal-warnings"
)

testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oFD")
parallelExecution := false // <- until TMap thread-safety issues are resolved

scalacOptions in (Compile, doc) ++= Seq(
"-doc-title", name.value,
"-doc-version", version.value,
"-doc-footer", projectName+" is developed by x.ai.",
"-sourcepath", (sourceDirectory in Compile).value.getPath, // needed for scaladoc to strip the location of the linked source path
"-doc-source-url", ghUrl+"/blob/"+version.value+"/src/main€{FILE_PATH}.scala",
"-implicits",
"-diagrams", // requires graphviz
"-groups"
)

publishTo := sonatypePublishTo.value

publishMavenStyle := true
publishArtifact in Test := false
pomIncludeRepository := { _ => false }

scalariformPreferences := scalariformPreferences.value
.setPreference(AlignParameters, true)
.setPreference(AlignArguments, true)
.setPreference(AlignSingleLineCaseStatements, true)
.setPreference(MultilineScaladocCommentsStartOnFirstLine, true)
.setPreference(SpaceInsideParentheses, true)
.setPreference(SpacesWithinPatternBinders, true)
.setPreference(SpacesAroundMultiImports, true)
.setPreference(DanglingCloseParenthesis, Preserve)
.setPreference(DoubleIndentConstructorArguments, true)
lazy val root = Project(id = projectName, base = file("."))
.aggregate(`play-json-extensions`.js, `play-json-extensions`.jvm)
.settings(sharedSettings)
.settings(publish / skip := true)

lazy val `play-json-extensions` = crossProject(JSPlatform, JVMPlatform)
.in(file("."))
.settings(sharedSettings)
.settings(
publishTo := sonatypePublishTo.value,
publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := { _ => false }
)
3 changes: 3 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.3")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1")
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.2")
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.3")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3")
Expand Down
9 changes: 3 additions & 6 deletions src/test/scala/PlayJsonExtensionsTest.scala
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package ai.x.test.play.json

import org.scalatest.FunSuite

import _root_.play.api.libs.json._

import ai.x.play.json._
import ai.x.play.json.tuples._

import ai.x.play.json.Encoders._
import org.scalatest.funsuite.AnyFunSuite

final case class RecursiveClass( o: Option[RecursiveClass], s: String )
object RecursiveClass {
Expand Down Expand Up @@ -62,7 +59,7 @@ case class Ua( i: Int ) extends OP
case class Unknown( json: JsValue ) extends OP
case class Uzzzzzzz( s: String ) extends OP

class PlayJsonExtensionsTest extends FunSuite {
class PlayJsonExtensionsTest extends AnyFunSuite {
test( "de/serialize symbol fields" ) {
case class SymbolFieldsClass( ### :Int, $$$: Double, %%% : Boolean, -+-+ : Seq[Int] )
implicit val fmt1 = Jsonx.formatCaseClass[SymbolFieldsClass]
Expand Down Expand Up @@ -332,7 +329,7 @@ abstract class JsonTestClasses {
case class ClassOuter2( outer: List[ListOuter2] )
object ClassOuter2 { implicit def jsonFormat = Jsonx.formatCaseClass[ClassOuter2] }
}
class JsonTests extends FunSuite {
class JsonTests extends AnyFunSuite {
test( "json optionWithNull" ) {
object JsonTestClasses extends JsonTestClasses {
implicit def option[A]( implicit reads: Reads[A] ): Reads[Option[A]] = implicits.optionWithNull[A]
Expand Down