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 1d84362..74f22b1 100644 --- a/build.sbt +++ b/build.sbt @@ -19,6 +19,7 @@ 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( scalaVersion := "2.11.12", @@ -33,6 +34,9 @@ val SharedSettings = 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") @@ -46,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/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") + } + } +} 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 @@ - +