Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Scala Native #29

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
target/
.js
.native
lowered.hnir
48 changes: 30 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,49 @@
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
- 2.12.6
- 2.13.0-M3
- 2.13.0-M4
- 2.12.10
- 2.13.1
jdk:
- oraclejdk8
- 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

cache:
env: SCALAJS_VERSION=1.0.0-M8
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
43 changes: 31 additions & 12 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import sbtcrossproject.crossProject
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.6", "2.11.12", "2.10.7", "2.13.0-M3", "2.13.0-M4")
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",
Expand All @@ -25,8 +28,15 @@ val commonSettings: Seq[Setting[_]] = Seq(
Some("scm:git:[email protected]:scala-js/scala-js-java-logging.git")))
)

lazy val root: Project = project.in(file(".")).
enablePlugins(ScalaJSPlugin).
val nativeSettings = Seq(
scalaVersion := scala211,
crossScalaVersions := Seq(scala211),
sources in (Compile,doc) := Seq.empty
)

lazy val root = crossProject(JSPlatform, NativePlatform).
crossType(CrossType.Pure).
in(file(".")).
settings(commonSettings).
settings(
name := "scalajs-java-logging",
Expand Down Expand Up @@ -64,7 +74,11 @@ lazy val root: Project = project.in(file(".")).
</developers>
),
pomIncludeRepository := { _ => false }
)
).
nativeSettings(nativeSettings)

lazy val rootJS = root.js
lazy val rootNative = root.native

lazy val testSuite = crossProject(JSPlatform, JVMPlatform).
jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin)).
Expand All @@ -76,12 +90,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)
11 changes: 11 additions & 0 deletions nativeTestSuite/src/test/scala/Main.scala
Original file line number Diff line number Diff line change
@@ -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"))
}
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.17
sbt.version=1.3.3
10 changes: 7 additions & 3 deletions project/build.sbt
Original file line number Diff line number Diff line change
@@ -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")