From 76f235f1cd7a1ab79ef7f31ccd86c604e0f46c96 Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Thu, 8 Mar 2018 17:05:35 -0800 Subject: Build for ScalaJS and Scala Native --- .ci/build | 11 ++++++++-- .travis.yml | 5 ++++- README.md | 6 +++--- build.sbt | 67 +++++++++++++++++++++++++++++++++++++------------------------ publish.sbt | 8 ++++---- 5 files changed, 61 insertions(+), 36 deletions(-) diff --git a/.ci/build b/.ci/build index 11f8e4e..a6c6ec0 100755 --- a/.ci/build +++ b/.ci/build @@ -1,7 +1,10 @@ #!/bin/bash set -ev -sbt scalafmtTest +mimaReportBinaryIssues +test +sbt \ + scalafmtTest \ + +sprayJsonDerivationJVM/mimaReportBinaryIssues \ + +test # Automatic publishing for tags that start with `v` if [[ "$TRAVIS_PULL_REQUEST" == "false" && "$TRAVIS_TAG" =~ ^v[0-9].* ]]; then @@ -23,5 +26,9 @@ if [[ "$TRAVIS_PULL_REQUEST" == "false" && "$TRAVIS_TAG" =~ ^v[0-9].* ]]; then EOF # Publish and release - sbt +publishSigned sonatypeRelease + sbt \ + +sprayJsonDerivationJVM/publishSigned \ + +sprayJsonDerivationJS/publishSigned \ + +sprayJsonDerivationNative/publishSigned \ + sonatypeRelease fi diff --git a/.travis.yml b/.travis.yml index 26ae139..5dddf69 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,11 @@ +sudo: required language: scala - jdk: - oraclejdk8 # this should be changed to openjdk as soon as it becomes available on Travis CI +before_install: + - curl https://raw.githubusercontent.com/scala-native/scala-native/68122ea1ce88ff0ccfb94cbbcd4dae34b68f21cf/scripts/travis_setup.sh | bash -x + env: - secure: "YkVvt6DGBUxfRRQ8LwxBWDets3BEZP+iS0PEzJLlOHdEyj5CDV7wDgIZgs/5Jme7TKSm5iCCVHFIJ0mnMrV7ZrqFBf0kKCicq/RYknR/fgggmiNztvg9RZhktTtk0rxNlWq2Ho0wighwIe7rDDEm0cbWuslg2DBWbZaGPVCpRQ3zUkpAKl338ztWgeH6C/u61ii1B5SyEN1rLVgMvoqN84YVwOSYeb3I4WIdWVVjtJyPNhSjgNGV6XudSQ3fTwv/XFMk9aGzbGnXu2KOADElfiTqqozwG3qSTiDjurcOLbGH9dAFVOz9bCdH7UCYamJ9M8a/RWINY7AJtxZ4ul15ksBqpVI8UxJhOSBrW15EYvLkTo+4IqWMcaodqakkUOjkbZUcUIShcA2JP+7PKk5Ap/Sg3t+ySumyKeNuaOebNgTbSdlrLRmg7Hl7L4sSddZf9p0M4HZ9UFLcm7UvLu+8PXe69BfE89qLEM0xJs1CG28w/uR6jN9uF2FzO6NWtdwZVGrTgXh7vvHYzDzdm74LoNKINk/zopC4sT6/+VVWCfX33oj2CkuvCLC4XwCOGeEMVKAtQFDIJ0t7j9wEwVrOy7USQfu/FcmZgXOBKvL5xP07VA4AY8MrNbwXSuHfrxJkzdj0M9XOdYyLJZK1h81fPVtWmP+DI6+Hf/KrVRjz9GY=" diff --git a/README.md b/README.md index 62d5adb..34221a6 100644 --- a/README.md +++ b/README.md @@ -12,15 +12,15 @@ It uses the [Magnolia](http://magnolia.work/) ([source code](https://github.com/propensive/magnolia)) typeclass derivation library to implicitly generate JSON formats for any product type. Magnolia integrates with spray seamlessly, to such a point that -a single contents of +the contents of [DerivedFormats.scala](src/main/scala/DerivedFormats.scala) provide almost all functionality. ## Getting Started Spray JSON Format Derivation is published to maven central as a Scala -library (for Scala version 2.12 and 2.11, support for ScalaJS -and Scala Native is pending). Include it in sbt by adding the +library (for Scala version 2.12 and 2.11, including support for ScalaJS +and Scala Native). Include it in sbt by adding the following snippet to your build.sbt: ```scala diff --git a/build.sbt b/build.sbt index ff91284..a13dab1 100644 --- a/build.sbt +++ b/build.sbt @@ -1,37 +1,52 @@ // shadow sbt-scalajs' crossProject and CrossType until Scala.js 1.0.0 is released import sbtcrossproject.{crossProject, CrossType} -lazy val sprayJsonDerivation = crossProject(JVMPlatform) - .crossType(CrossType.Full) - .in(file(".")) - .settings( - name := "spray-json-derivation", - version in ThisBuild := { - import sys.process._ - ("git describe --always --dirty=-SNAPSHOT --match v[0-9].*" !!).tail.trim - }, - crossScalaVersions := "2.12.4" :: "2.11.12" :: Nil, - scalaVersion := crossScalaVersions.value.head, - scalacOptions ++= Seq( - "-feature", - "-deprecation", - "-Xlint", - "-Xfatal-warnings" - ), - libraryDependencies ++= Seq( - "io.spray" %%% "spray-json" % "1.3.4", - "com.propensive" %%% "magnolia" % "0.7.1", - "org.scalatest" %%% "scalatest" % "3.0.2" % "test" +lazy val sprayJsonDerivation = + crossProject(JVMPlatform, JSPlatform, NativePlatform) + .crossType(CrossType.Full) + .in(file(".")) + .settings( + name := "spray-json-derivation", + version in ThisBuild := { + import sys.process._ + ("git describe --always --dirty=-SNAPSHOT --match v[0-9].*" !!).tail.trim + }, + scalaVersion := crossScalaVersions.value.head, + scalacOptions ++= Seq( + "-feature", + "-deprecation", + "-Xlint", + "-Xfatal-warnings" + ), + libraryDependencies ++= Seq( + "io.crashbox" %%% "spray-json" % "1.3.4-1", + "com.propensive" %%% "magnolia" % "0.7.1" + ) + ) + .platformsSettings(JVMPlatform, JSPlatform)( + libraryDependencies += "org.scalatest" %%% "scalatest" % "3.0.3" % "test" + ) + .jvmSettings( + mimaPreviousArtifacts := Set( + "xyz.driver" %% "spray-json-derivation" % "0.3.1"), + crossScalaVersions := "2.12.4" :: "2.11.12" :: Nil + ) + .jsSettings( + crossScalaVersions := "2.12.4" :: "2.11.12" :: Nil + ) + .nativeSettings( + crossScalaVersions := "2.11.12" :: Nil, + unmanagedSourceDirectories in Test := Seq.empty ) - ) - .jvmSettings( - mimaPreviousArtifacts := Set("xyz.driver" %% "spray-json-derivation" % "0.3.1") - ) lazy val sprayJsonDerivationJVM = sprayJsonDerivation.jvm +lazy val sprayJsonDerivationJS = sprayJsonDerivation.js +lazy val sprayJsonDerivationNative = sprayJsonDerivation.native lazy val root = (project in file(".")) - .aggregate(sprayJsonDerivationJVM) + .aggregate(sprayJsonDerivationJVM, + sprayJsonDerivationJS, + sprayJsonDerivationNative) .settings( publish := {}, publishLocal := {} diff --git a/publish.sbt b/publish.sbt index b067239..55d3917 100644 --- a/publish.sbt +++ b/publish.sbt @@ -1,24 +1,24 @@ -organization := "xyz.driver" +organization in ThisBuild := "xyz.driver" licenses in ThisBuild := Seq( ("Apache 2.0", url("https://www.apache.org/licenses/LICENSE-2.0"))) homepage in ThisBuild := Some( url("https://github.com/drivergroup/spray-json-derivation")) publishMavenStyle in ThisBuild := true -publishTo := Some( +publishTo in ThisBuild := Some( if (isSnapshot.value) Opts.resolver.sonatypeSnapshots else Opts.resolver.sonatypeStaging ) -scmInfo := Some( +scmInfo in ThisBuild := Some( ScmInfo( url("https://github.com/drivergroup/spray-json-derivation"), "scm:git@github.com:drivergroup/spray-json-derivation.git" ) ) -developers := List( +developers in ThisBuild := List( Developer( id = "jodersky", name = "Jakob Odersky", -- cgit v1.2.3