Skip to content

Commit 8e0853f

Browse files
committed
Support Scala Native
1 parent dd02db3 commit 8e0853f

File tree

6 files changed

+67
-17
lines changed

6 files changed

+67
-17
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
target/
2+
.js
3+
.native

.travis.yml

+24-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
sudo: false
22
language: scala
33
script:
4-
- sbt ++$TRAVIS_SCALA_VERSION root/scalastyle testSuiteJVM/scalastyle testSuiteJVM/test:scalastyle testSuiteJS/scalastyle testSuiteJS/test:scalastyle
4+
- sbt ++$TRAVIS_SCALA_VERSION rootJS/scalastyle testSuiteJVM/scalastyle testSuiteJVM/test:scalastyle testSuiteJS/scalastyle testSuiteJS/test:scalastyle
55
- sbt ++$TRAVIS_SCALA_VERSION testSuiteJVM/test
66
- sbt ++$TRAVIS_SCALA_VERSION testSuiteJS/test
77
- sbt ++$TRAVIS_SCALA_VERSION 'set scalaJSStage in Global := FullOptStage' testSuiteJS/test
8-
- sbt ++$TRAVIS_SCALA_VERSION publishLocal
8+
- sbt ++$TRAVIS_SCALA_VERSION rootJS/publishLocal
99
scala:
1010
- 2.10.7
1111
- 2.11.12
@@ -26,12 +26,30 @@ matrix:
2626
env: SCALAJS_VERSION=1.0.0-M3
2727
- scala: 2.10.7
2828
env: SCALAJS_VERSION=1.0.0-M5
29-
30-
cache:
29+
include:
30+
- scala: 2.11.12
31+
jdk: openjdk8
32+
env:
33+
- SCALA_NATIVE_VERSION="0.3.9"
34+
sudo: required
35+
before_install:
36+
- curl https://raw.githubusercontent.com/scala-native/scala-native/master/scripts/travis_setup.sh | bash -
37+
script:
38+
- sbt "++$TRAVIS_SCALA_VERSION!" nativeTestSuite/test rootNative/publishLocal
39+
- scala: 2.11.12
40+
jdk: openjdk8
41+
env:
42+
- SCALA_NATIVE_VERSION="0.4.0-M2"
43+
sudo: required
44+
before_install:
45+
- curl https://raw.githubusercontent.com/scala-native/scala-native/master/scripts/travis_setup.sh | bash -
46+
script:
47+
- sbt "++$TRAVIS_SCALA_VERSION!" nativeTestSuite/test rootNative/publishLocal
48+
cache:
3149
directories:
32-
- "$HOME/.ivy2/cache"
50+
- "$HOME/.cache/coursier/v1"
3351
- "$HOME/.sbt"
3452
before_cache:
3553
# Cleanup the cached directories to avoid unnecessary cache updates
36-
- find $HOME/.ivy2/cache -name "ivydata-*.properties" -print -delete
54+
- find $HOME/.coursier -name "*.lock" | xargs rm
3755
- find $HOME/.sbt -name "*.lock" -print -delete

build.sbt

+22-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import sbtcrossproject.crossProject
1+
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}
22

33
crossScalaVersions in ThisBuild := {
44
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(
2525
Some("scm:git:[email protected]:scala-js/scala-js-java-logging.git")))
2626
)
2727

28-
lazy val root: Project = project.in(file(".")).
29-
enablePlugins(ScalaJSPlugin).
28+
val nativeSettings = Seq(
29+
scalaVersion := "2.11.12",
30+
crossScalaVersions := Seq("2.11.12")
31+
)
32+
33+
lazy val root = crossProject(JSPlatform, NativePlatform).
34+
crossType(CrossType.Pure).
35+
in(file(".")).
3036
settings(commonSettings).
3137
settings(
3238
name := "scalajs-java-logging",
@@ -64,7 +70,11 @@ lazy val root: Project = project.in(file(".")).
6470
</developers>
6571
),
6672
pomIncludeRepository := { _ => false }
67-
)
73+
).
74+
nativeSettings(nativeSettings)
75+
76+
lazy val rootJS = root.js
77+
lazy val rootNative = root.native
6878

6979
lazy val testSuite = crossProject(JSPlatform, JVMPlatform).
7080
jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin)).
@@ -76,12 +86,17 @@ lazy val testSuite = crossProject(JSPlatform, JVMPlatform).
7686
jsSettings(
7787
name := "java.logging testSuite on JS"
7888
).
79-
jsConfigure(_.dependsOn(root)).
89+
jsConfigure(_.dependsOn(rootJS)).
8090
jvmSettings(
8191
name := "java.logging testSuite on JVM",
8292
libraryDependencies +=
8393
"com.novocode" % "junit-interface" % "0.9" % "test"
8494
)
8595

86-
lazy val testSuiteJS = testSuite.js
87-
lazy val testSuiteJVM = testSuite.jvm
96+
lazy val nativeTestSuite = project.
97+
settings(
98+
name := "java.logging testSuite on Native",
99+
nativeSettings
100+
).
101+
dependsOn(rootNative).
102+
enablePlugins(ScalaNativePlugin)
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import java.util.logging._
2+
3+
object Main {
4+
def main(args: Array[String]): Unit = {
5+
val f = new SimpleFormatter()
6+
val r = new LogRecord(Level.INFO, "message")
7+
r.setLoggerName("logger")
8+
assert(f.format(r).contains("message"))
9+
assert(f.format(r).contains("logger"))
10+
}
11+
}

project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.13.17
1+
sbt.version=1.3.3

project/build.sbt

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
val scalaJSVersion =
2-
Option(System.getenv("SCALAJS_VERSION")).getOrElse("0.6.24")
2+
Option(System.getenv("SCALAJS_VERSION")).getOrElse("0.6.29")
3+
val scalaNativeVersion =
4+
Option(System.getenv("SCALANATIVE_VERSION")).getOrElse("0.3.9")
35

46
addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion)
5-
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.5.0")
7+
addSbtPlugin("org.scala-native" % "sbt-scala-native" % scalaNativeVersion)
8+
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.1")
9+
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "0.6.1")
610

7-
addSbtPlugin("org.scalastyle" % "scalastyle-sbt-plugin" % "0.8.0")
11+
addSbtPlugin("org.scalastyle" % "scalastyle-sbt-plugin" % "1.0.0")

0 commit comments

Comments
 (0)