From 8e0853f85855e4903d6fe7a11b9c6a95814064a4 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Fri, 15 Nov 2019 21:31:07 +0100 Subject: [PATCH 1/5] Support Scala Native --- .gitignore | 2 ++ .travis.yml | 30 ++++++++++++++++++----- build.sbt | 29 ++++++++++++++++------ nativeTestSuite/src/test/scala/Main.scala | 11 +++++++++ project/build.properties | 2 +- project/build.sbt | 10 +++++--- 6 files changed, 67 insertions(+), 17 deletions(-) create mode 100644 nativeTestSuite/src/test/scala/Main.scala diff --git a/.gitignore b/.gitignore index 2f7896d..31965bb 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ target/ +.js +.native diff --git a/.travis.yml b/.travis.yml index d58183d..d5883d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,11 @@ sudo: false language: scala script: - - sbt ++$TRAVIS_SCALA_VERSION root/scalastyle testSuiteJVM/scalastyle testSuiteJVM/test:scalastyle testSuiteJS/scalastyle testSuiteJS/test:scalastyle + - sbt ++$TRAVIS_SCALA_VERSION rootJS/scalastyle testSuiteJVM/scalastyle testSuiteJVM/test:scalastyle testSuiteJS/scalastyle testSuiteJS/test:scalastyle - sbt ++$TRAVIS_SCALA_VERSION testSuiteJVM/test - sbt ++$TRAVIS_SCALA_VERSION testSuiteJS/test - sbt ++$TRAVIS_SCALA_VERSION 'set scalaJSStage in Global := FullOptStage' testSuiteJS/test - - sbt ++$TRAVIS_SCALA_VERSION publishLocal + - sbt ++$TRAVIS_SCALA_VERSION rootJS/publishLocal scala: - 2.10.7 - 2.11.12 @@ -26,12 +26,30 @@ matrix: env: SCALAJS_VERSION=1.0.0-M3 - scala: 2.10.7 env: SCALAJS_VERSION=1.0.0-M5 - -cache: + include: + - scala: 2.11.12 + jdk: openjdk8 + env: + - SCALA_NATIVE_VERSION="0.3.9" + sudo: required + before_install: + - curl https://raw.githubusercontent.com/scala-native/scala-native/master/scripts/travis_setup.sh | bash - + script: + - sbt "++$TRAVIS_SCALA_VERSION!" nativeTestSuite/test rootNative/publishLocal + - scala: 2.11.12 + jdk: openjdk8 + env: + - SCALA_NATIVE_VERSION="0.4.0-M2" + sudo: required + before_install: + - curl https://raw.githubusercontent.com/scala-native/scala-native/master/scripts/travis_setup.sh | bash - + script: + - sbt "++$TRAVIS_SCALA_VERSION!" nativeTestSuite/test rootNative/publishLocal + cache: directories: - - "$HOME/.ivy2/cache" + - "$HOME/.cache/coursier/v1" - "$HOME/.sbt" before_cache: # Cleanup the cached directories to avoid unnecessary cache updates - - find $HOME/.ivy2/cache -name "ivydata-*.properties" -print -delete + - find $HOME/.coursier -name "*.lock" | xargs rm - find $HOME/.sbt -name "*.lock" -print -delete diff --git a/build.sbt b/build.sbt index b5c15fd..a328125 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,4 @@ -import sbtcrossproject.crossProject +import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType} crossScalaVersions in ThisBuild := { val allVersions = Seq("2.12.6", "2.11.12", "2.10.7", "2.13.0-M3", "2.13.0-M4") @@ -25,8 +25,14 @@ val commonSettings: Seq[Setting[_]] = Seq( Some("scm:git:git@github.com:scala-js/scala-js-java-logging.git"))) ) -lazy val root: Project = project.in(file(".")). - enablePlugins(ScalaJSPlugin). +val nativeSettings = Seq( + scalaVersion := "2.11.12", + crossScalaVersions := Seq("2.11.12") +) + +lazy val root = crossProject(JSPlatform, NativePlatform). + crossType(CrossType.Pure). + in(file(".")). settings(commonSettings). settings( name := "scalajs-java-logging", @@ -64,7 +70,11 @@ lazy val root: Project = project.in(file(".")). ), pomIncludeRepository := { _ => false } - ) + ). + nativeSettings(nativeSettings) + +lazy val rootJS = root.js +lazy val rootNative = root.native lazy val testSuite = crossProject(JSPlatform, JVMPlatform). jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin)). @@ -76,12 +86,17 @@ lazy val testSuite = crossProject(JSPlatform, JVMPlatform). jsSettings( name := "java.logging testSuite on JS" ). - jsConfigure(_.dependsOn(root)). + jsConfigure(_.dependsOn(rootJS)). jvmSettings( name := "java.logging testSuite on JVM", libraryDependencies += "com.novocode" % "junit-interface" % "0.9" % "test" ) -lazy val testSuiteJS = testSuite.js -lazy val testSuiteJVM = testSuite.jvm +lazy val nativeTestSuite = project. + settings( + name := "java.logging testSuite on Native", + nativeSettings + ). + dependsOn(rootNative). + enablePlugins(ScalaNativePlugin) diff --git a/nativeTestSuite/src/test/scala/Main.scala b/nativeTestSuite/src/test/scala/Main.scala new file mode 100644 index 0000000..de36d98 --- /dev/null +++ b/nativeTestSuite/src/test/scala/Main.scala @@ -0,0 +1,11 @@ +import java.util.logging._ + +object Main { + def main(args: Array[String]): Unit = { + val f = new SimpleFormatter() + val r = new LogRecord(Level.INFO, "message") + r.setLoggerName("logger") + assert(f.format(r).contains("message")) + assert(f.format(r).contains("logger")) + } +} \ No newline at end of file diff --git a/project/build.properties b/project/build.properties index 133a8f1..6adcdc7 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.17 +sbt.version=1.3.3 diff --git a/project/build.sbt b/project/build.sbt index 8a1e3fd..f1e66c2 100644 --- a/project/build.sbt +++ b/project/build.sbt @@ -1,7 +1,11 @@ val scalaJSVersion = - Option(System.getenv("SCALAJS_VERSION")).getOrElse("0.6.24") + Option(System.getenv("SCALAJS_VERSION")).getOrElse("0.6.29") +val scalaNativeVersion = + Option(System.getenv("SCALANATIVE_VERSION")).getOrElse("0.3.9") addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion) -addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.5.0") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % scalaNativeVersion) +addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.1") +addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "0.6.1") -addSbtPlugin("org.scalastyle" % "scalastyle-sbt-plugin" % "0.8.0") +addSbtPlugin("org.scalastyle" % "scalastyle-sbt-plugin" % "1.0.0") From 1301da6802352e0b0760baa35474efb126251f18 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Fri, 15 Nov 2019 22:16:37 +0100 Subject: [PATCH 2/5] fix: Remove docs from native target Fix "dropping dependency on node with no phase object: mixin" --- build.sbt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index a328125..d5893cd 100644 --- a/build.sbt +++ b/build.sbt @@ -27,7 +27,8 @@ val commonSettings: Seq[Setting[_]] = Seq( val nativeSettings = Seq( scalaVersion := "2.11.12", - crossScalaVersions := Seq("2.11.12") + crossScalaVersions := Seq("2.11.12"), + sources in (Compile,doc) := Seq.empty ) lazy val root = crossProject(JSPlatform, NativePlatform). From 78ab4c6c8ebf23452bbe032e5f6d9e2b5af41043 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Fri, 15 Nov 2019 22:19:43 +0100 Subject: [PATCH 3/5] Add lowered.hnir to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 31965bb..d102803 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ target/ .js .native +lowered.hnir From cf5565cf9166e6671f72b4fea3ec0b4d9c98e27a Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Sat, 16 Nov 2019 09:09:29 +0100 Subject: [PATCH 4/5] Change travis jdk to OpenJDK --- .travis.yml | 2 +- build.sbt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d5883d6..0929a80 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ scala: - 2.13.0-M3 - 2.13.0-M4 jdk: - - oraclejdk8 + - openjdk8 env: - SCALAJS_VERSION=0.6.23 - SCALAJS_VERSION=1.0.0-M3 diff --git a/build.sbt b/build.sbt index d5893cd..dbf5e21 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,7 @@ import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType} crossScalaVersions in ThisBuild := { - val allVersions = Seq("2.12.6", "2.11.12", "2.10.7", "2.13.0-M3", "2.13.0-M4") + val allVersions = Seq("2.12.10", "2.11.12", "2.10.7", "2.13.1") if (scalaJSVersion.startsWith("0.6.")) allVersions else if (scalaJSVersion == "1.0.0-M3") From 1a4b5a83217f669e929ca3ac36d0fbbc1675fe9d Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Sat, 16 Nov 2019 10:20:37 +0100 Subject: [PATCH 5/5] Update Scala versions and clean build.sbt --- .travis.yml | 16 +++++----------- build.sbt | 17 ++++++++++------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0929a80..2052eca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,23 +9,17 @@ script: scala: - 2.10.7 - 2.11.12 - - 2.12.6 - - 2.13.0-M3 - - 2.13.0-M4 + - 2.12.10 + - 2.13.1 jdk: - openjdk8 env: - - SCALAJS_VERSION=0.6.23 - - SCALAJS_VERSION=1.0.0-M3 - - SCALAJS_VERSION=1.0.0-M5 + - SCALAJS_VERSION=0.6.29 + - SCALAJS_VERSION=1.0.0-M8 matrix: exclude: - scala: 2.10.7 - env: SCALAJS_VERSION=1.0.0-M3 - - scala: 2.13.0-M4 - env: SCALAJS_VERSION=1.0.0-M3 - - scala: 2.10.7 - env: SCALAJS_VERSION=1.0.0-M5 + env: SCALAJS_VERSION=1.0.0-M8 include: - scala: 2.11.12 jdk: openjdk8 diff --git a/build.sbt b/build.sbt index dbf5e21..9645cf4 100644 --- a/build.sbt +++ b/build.sbt @@ -1,15 +1,18 @@ import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType} +val scala210 = "2.10.7" +val scala211 = "2.11.12" +val scala212 = "2.12.10" +val scala213 = "2.13.1" + crossScalaVersions in ThisBuild := { - val allVersions = Seq("2.12.10", "2.11.12", "2.10.7", "2.13.1") + val allVersions = Seq(scala210, scala211, scala212, scala213) if (scalaJSVersion.startsWith("0.6.")) allVersions - else if (scalaJSVersion == "1.0.0-M3") - allVersions.filter(v => !v.startsWith("2.10.") && v != "2.13.0-M4") else - allVersions.filter(!_.startsWith("2.10.")) + allVersions.filter(_ != scala210) } -scalaVersion in ThisBuild := (crossScalaVersions in ThisBuild).value.head +scalaVersion in ThisBuild := scala212 val commonSettings: Seq[Setting[_]] = Seq( version := "0.1.6-SNAPSHOT", @@ -26,8 +29,8 @@ val commonSettings: Seq[Setting[_]] = Seq( ) val nativeSettings = Seq( - scalaVersion := "2.11.12", - crossScalaVersions := Seq("2.11.12"), + scalaVersion := scala211, + crossScalaVersions := Seq(scala211), sources in (Compile,doc) := Seq.empty )