From 8c6aa0cefd0624f4807d83fbfe1b42bc6f37f349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=BBabi=C5=84ski?= Date: Wed, 12 Dec 2018 08:06:34 +0100 Subject: [PATCH 1/3] add slogging --- build.sbt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build.sbt b/build.sbt index 1d84362..1cffd90 100644 --- a/build.sbt +++ b/build.sbt @@ -20,6 +20,8 @@ scapegoatVersion in ThisBuild := "1.3.8" scalacOptions ++= scalacOptionsFor(scalaVersion.value) val ScalaPropsVersion = "0.5.5" +val SloggingVersion = "0.6.1" + val SharedSettings = Seq( scalaVersion := "2.11.12", scalacOptions ++= scalacOptionsFor(scalaVersion.value), @@ -28,6 +30,9 @@ val SharedSettings = Seq( mainClass in (Compile, run) := Some("pl.writeonly.re.main.Main"), testFrameworks += new TestFramework("utest.runner.Framework"), resolvers += Opts.resolver.sonatypeReleases, + libraryDependencies ++= Seq( + "biz.enef" %%% "slogging" % SloggingVersion, + ), libraryDependencies += "com.lihaoyi" %%% "utest" % "0.6.5" % "test", libraryDependencies ++= Seq( "com.github.scalaprops" %%% "scalaprops" % ScalaPropsVersion % "test,it", From cdd3752de4570c8e06c52b34e7c67d54d075b45b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=BBabi=C5=84ski?= Date: Wed, 12 Dec 2018 08:14:51 +0100 Subject: [PATCH 2/3] use slogging --- README.md | 31 ++++++++++++------- build.sbt | 7 ++--- .../scala/pl/writeonly/re/shared/Core.scala | 11 +++++-- .../writeonly/re/shared/LazyLoggingCore.scala | 9 ++++++ .../re/shared/StrictLoggingCore.scala | 9 ++++++ .../pl/writeonly/re/shared/CoreTest.scala | 11 +++++++ 6 files changed, 60 insertions(+), 18 deletions(-) create mode 100644 re/shared/src/main/scala/pl/writeonly/re/shared/LazyLoggingCore.scala create mode 100644 re/shared/src/main/scala/pl/writeonly/re/shared/StrictLoggingCore.scala create mode 100644 re/shared/src/test/scala/pl/writeonly/re/shared/CoreTest.scala diff --git a/README.md b/README.md index 80b7b58..22f709c 100644 --- a/README.md +++ b/README.md @@ -9,37 +9,37 @@ cd resentiment Refactor and reformat: ```bash -sbt scalafix test:scalafix it:scalafix && \ +sbt scalafix test:scalafix it:scalafix && sbt scalafmtSbt scalafmt test:scalafmt it:scalafmt ``` Check lint and format: ```bash -sbt 're/scalafix --check' 're/test:scalafix --check' 're/it:scalafix --check' && \ +sbt 're/scalafix --check' 're/test:scalafix --check' 're/it:scalafix --check' && sbt scalafmtSbtCheck re/scalafmtCheck re/test:scalafmtCheck re/it:scalafmtCheck ``` Compile, test and generate coverage report: ```bash -sbt clean compile test:compile it:compile re/test && \ -sbt coverage reJS/test reJVM/test reJS/it:test reJVM/it:test coverageReport && +sbt clean compile test:compile it:compile re/test && +sbt coverage reJS/test reJVM/test reJS/it:test reJVM/it:test coverageReport && sbt coverageAggregate ``` Check: ```bash -sbt scalastyle test:scalastyle it:scalastyle && \ +sbt scalastyle test:scalastyle it:scalastyle && sbt scapegoat cpd stats ``` All: ```bash -sbt re/scalafix re/test:scalafix re/it:scalafix && \ -sbt re/scalafmtSbt re/scalafmt re/test:scalafmt re/it:scalafmt && \ -sbt clean re/compile re/test:compile re/it:compile re/test && \ -sbt coverage reJS/test reJVM/test reJS/it:test reJVM/it:test coverageReport && \ -sbt coverageAggregate && \ -sbt scalastyle test:scalastyle it:scalastyle && \ +sbt re/scalafix re/test:scalafix re/it:scalafix && +sbt re/scalafmtSbt re/scalafmt re/test:scalafmt re/it:scalafmt && +sbt clean re/compile re/test:compile re/it:compile re/test && +sbt coverage reJS/test reJVM/test reJS/it:test reJVM/it:test coverageReport && +sbt coverageAggregate && +sbt scalastyle test:scalastyle it:scalastyle && sbt scapegoat cpd stats ``` @@ -53,3 +53,12 @@ sbt coverageAggregate && sbt scalastyle test:scalastyle it:scalastyle && sbt scapegoat cpd stats ``` + +Only Scala Native +```bash +sbt re/scalafix re/test:scalafix re/it:scalafix && +sbt re/scalafmtSbt re/scalafmt re/test:scalafmt re/it:scalafmt && +sbt clean re/compile re/test:compile re/it:compile re/test && +sbt scalastyle test:scalastyle it:scalastyle && +sbt scapegoat cpd stats +``` diff --git a/build.sbt b/build.sbt index 1cffd90..f66e4ab 100644 --- a/build.sbt +++ b/build.sbt @@ -19,7 +19,6 @@ scalaVersion := "2.11.12" scapegoatVersion in ThisBuild := "1.3.8" scalacOptions ++= scalacOptionsFor(scalaVersion.value) val ScalaPropsVersion = "0.5.5" - val SloggingVersion = "0.6.1" val SharedSettings = Seq( @@ -30,14 +29,14 @@ val SharedSettings = Seq( mainClass in (Compile, run) := Some("pl.writeonly.re.main.Main"), testFrameworks += new TestFramework("utest.runner.Framework"), resolvers += Opts.resolver.sonatypeReleases, - libraryDependencies ++= Seq( - "biz.enef" %%% "slogging" % SloggingVersion, - ), libraryDependencies += "com.lihaoyi" %%% "utest" % "0.6.5" % "test", libraryDependencies ++= Seq( "com.github.scalaprops" %%% "scalaprops" % ScalaPropsVersion % "test,it", "com.github.scalaprops" %%% "scalaprops-scalazlaws" % ScalaPropsVersion % "test,it", ), + libraryDependencies ++= Seq( + "biz.enef" %%% "slogging" % SloggingVersion, + ), scalaJSUseMainModuleInitializer := true, scalaJSMainModuleInitializer := Some( ModuleInitializer.mainMethod(mainClassString, "main") diff --git a/re/shared/src/main/scala/pl/writeonly/re/shared/Core.scala b/re/shared/src/main/scala/pl/writeonly/re/shared/Core.scala index 84b634a..9416ce9 100644 --- a/re/shared/src/main/scala/pl/writeonly/re/shared/Core.scala +++ b/re/shared/src/main/scala/pl/writeonly/re/shared/Core.scala @@ -1,7 +1,12 @@ package pl.writeonly.re.shared -object Core { - def apply(arg: String): Unit = { - println(s"Hello Scala $arg!") +trait Core { + def apply(arg: String): Unit +} + +object Core extends Core { + override def apply(arg: String): Unit = { + StrictLoggingCore(arg) + LazyLoggingCore(arg) } } diff --git a/re/shared/src/main/scala/pl/writeonly/re/shared/LazyLoggingCore.scala b/re/shared/src/main/scala/pl/writeonly/re/shared/LazyLoggingCore.scala new file mode 100644 index 0000000..417133b --- /dev/null +++ b/re/shared/src/main/scala/pl/writeonly/re/shared/LazyLoggingCore.scala @@ -0,0 +1,9 @@ +package pl.writeonly.re.shared + +import slogging.LazyLogging + +object LazyLoggingCore extends Core with LazyLogging { + def apply(arg: String): Unit = { + logger.info(s"Hello Scala $arg!") + } +} diff --git a/re/shared/src/main/scala/pl/writeonly/re/shared/StrictLoggingCore.scala b/re/shared/src/main/scala/pl/writeonly/re/shared/StrictLoggingCore.scala new file mode 100644 index 0000000..e8c2229 --- /dev/null +++ b/re/shared/src/main/scala/pl/writeonly/re/shared/StrictLoggingCore.scala @@ -0,0 +1,9 @@ +package pl.writeonly.re.shared + +import slogging.StrictLogging + +object StrictLoggingCore extends Core with StrictLogging { + def apply(arg: String): Unit = { + logger.info(s"Hello Scala $arg!") + } +} diff --git a/re/shared/src/test/scala/pl/writeonly/re/shared/CoreTest.scala b/re/shared/src/test/scala/pl/writeonly/re/shared/CoreTest.scala new file mode 100644 index 0000000..cf64eae --- /dev/null +++ b/re/shared/src/test/scala/pl/writeonly/re/shared/CoreTest.scala @@ -0,0 +1,11 @@ +package pl.writeonly.re.shared + +import utest._ + +object CoreTest extends TestSuite { + override val tests: Tests = Tests { + 'core - { + Core("Awesome") + } + } +} From 6988a9bd53193f392c912242bf0e0d9b594a1971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=BBabi=C5=84ski?= Date: Wed, 12 Dec 2018 09:03:18 +0100 Subject: [PATCH 3/3] fix scalastyle-config --- build.sbt | 13 ++++++++++++- scalastyle-config.xml | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index f66e4ab..74f22b1 100644 --- a/build.sbt +++ b/build.sbt @@ -50,15 +50,26 @@ val jsSettings = Seq( mainClass in Compile := mainClassSome, scalaJSUseMainModuleInitializer := true, coverageEnabled := true, + libraryDependencies ++= Seq( + "biz.enef" %%% "slogging-winston" % SloggingVersion, + ), ) val jvmSettings = Seq( mainClass in Compile := mainClassSome, scalaJSUseMainModuleInitializer := true, coverageEnabled := true, + libraryDependencies ++= Seq( + "ch.qos.logback" % "logback-classic" % "1.2.3", + ), ) -val nativeSettings = Seq(nativeLinkStubs := true) +val nativeSettings = Seq( + nativeLinkStubs := true, + libraryDependencies ++= Seq( + "biz.enef" %%% "slogging-syslog" % SloggingVersion, + ), +) lazy val re = crossProject(JSPlatform, JVMPlatform, NativePlatform) .withoutSuffixFor(NativePlatform) diff --git a/scalastyle-config.xml b/scalastyle-config.xml index b6fb399..7f6995b 100644 --- a/scalastyle-config.xml +++ b/scalastyle-config.xml @@ -55,7 +55,7 @@ - +