Skip to content

Commit

Permalink
Update build and release configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
makiftutuncu committed Feb 12, 2020
1 parent a3f7491 commit dac7a8c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
12 changes: 10 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// === Project Definition ===

description in ThisBuild := "A zero-dependency micro library for handling errors"
description in ThisBuild := "A zero-dependency micro library to deal with errors"
homepage in ThisBuild := Some(url("https://github.com/makiftutuncu/e"))
startYear in ThisBuild := Some(2019)
licenses in ThisBuild := Seq("MIT" -> url("https://opensource.org/licenses/MIT"))
Expand Down Expand Up @@ -92,13 +92,21 @@ pomIncludeRepository in ThisBuild := { _ => false }
publishMavenStyle in ThisBuild := true
publishTo in ThisBuild := { Some(if (isSnapshot.value) "snapshots" at "https://oss.sonatype.org/content/repositories/snapshots" else "releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2") }

val updateDocumentation = ReleaseStep(
releaseStepCommand("e-docs/mdoc") andThen { st =>
import sys.process._
"git add -A".!
st
}
)

releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
releaseStepCommandAndRemaining("e-docs/mdoc"),
updateDocumentation,
commitReleaseVersion,
tagRelease,
releaseStepCommandAndRemaining("e-core/publishSigned"),
Expand Down
10 changes: 5 additions & 5 deletions e-circe/src/main/scala/e/circe/CodecForCirceJson.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ object CodecForCirceJson extends Codec[Json] {

override def encode(e: E): Json = {
val jsons = List(
Option.when(e.hasName)(Json.obj("name" := e.name)),
Option.when(e.hasMessage)(Json.obj("message" := e.message)),
Option.when(e.hasCode)(Json.obj("code" := e.code)),
e.cause.fold[Option[Json]](None)(c => Some(Json.obj("cause" := c.getMessage))),
Option.when(e.hasData)(Json.obj("data" := e.data)),
if (e.hasName) Some (Json.obj("name" := e.name)) else None,
if (e.hasMessage) Some (Json.obj("message" := e.message)) else None,
if (e.hasCode) Some (Json.obj("code" := e.code)) else None,
e.cause.map(c => Json.obj("cause" := c.getMessage)),
if (e.hasData) Some (Json.obj("data" := e.data)) else None
)

jsons.foldLeft(Json.obj()) {
Expand Down
10 changes: 5 additions & 5 deletions e-play-json/src/main/scala/e/playjson/CodecForPlayJson.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ object CodecForPlayJson extends Codec[JsValue] {

override def encode(e: E): JsValue = {
val jsons = List(
Option.when(e.hasName)(Json.obj("name" -> e.name)),
Option.when(e.hasMessage)(Json.obj("message" -> e.message)),
Option.when(e.hasCode)(Json.obj("code" -> e.code)),
e.cause.fold[Option[JsObject]](None)(c => Some(Json.obj("cause" -> c.getMessage))),
Option.when(e.hasData)(Json.obj("data" -> e.data)),
if (e.hasName) Some(Json.obj("name" -> e.name)) else None,
if (e.hasMessage) Some(Json.obj("message" -> e.message)) else None,
if (e.hasCode) Some(Json.obj("code" -> e.code)) else None,
e.cause.map(c => Json.obj("cause" -> c.getMessage)),
if (e.hasData) Some(Json.obj("data" -> e.data)) else None
)

jsons.foldLeft(Json.obj()) {
Expand Down
8 changes: 4 additions & 4 deletions e-scala/src/main/scala/e/scala/JsonStringEncoder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package e.scala
object JsonStringEncoder extends Encoder[String] {
override def encode(e: E): String =
List(
Option.when(e.hasName)("name" -> s""""${escape(e.name)}""""),
Option.when(e.hasMessage)("message" -> s""""${escape(e.message)}""""),
Option.when(e.hasCode)("code" -> s"${e.code}"),
if (e.hasName) Some("name" -> s""""${escape(e.name)}"""") else None,
if (e.hasMessage) Some("message" -> s""""${escape(e.message)}"""") else None,
if (e.hasCode) Some("code" -> s"${e.code}") else None,
encodeCause(e.cause).map(c => "cause" -> c),
Option.when(e.hasData)("data" -> s"${encodeData(e.data)}")
if (e.hasData) Some("data" -> s"${encodeData(e.data)}") else None
).collect {
case Some((k, v)) => s""""$k":$v"""
}.mkString("{", ",", "}")
Expand Down
3 changes: 1 addition & 2 deletions project/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ object Settings {

lazy val commonSettings = Seq(
resolvers += Resolver.jcenterRepo,
Compile / compileOrder := CompileOrder.JavaThenScala,
javacOptions ++= Seq("-source", javaVersion, "-target", javaVersion, "-Xlint")
Compile / compileOrder := CompileOrder.JavaThenScala
)

lazy val mdocSettings = Seq(
Expand Down

0 comments on commit dac7a8c

Please sign in to comment.