Skip to content

Commit 0bb9c4e

Browse files
committed
Support scala native
1 parent 2554d9e commit 0bb9c4e

File tree

4 files changed

+27
-23
lines changed

4 files changed

+27
-23
lines changed

Diff for: build.sbt

+17-15
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,24 @@ lazy val scala3 = "3.0.2"
2323
ThisBuild / scalaVersion := scala213
2424
ThisBuild / scalafixDependencies += organizeImports
2525

26-
lazy val root = project
26+
lazy val root = crossProject(JVMPlatform, NativePlatform)
27+
.crossType(CrossType.Pure)
2728
.in(file("."))
2829
.settings(
29-
name := "Python Native Libs",
30-
crossScalaVersions := Seq(scala212, scala213, scala3),
30+
name := "Python Native Libs",
31+
sonatypeCredentialHost := "s01.oss.sonatype.org",
32+
sonatypeRepository := "https://s01.oss.sonatype.org/service/local",
3133
libraryDependencies ++= Seq(
32-
scalaCollectionCompat,
33-
scalapy % Test,
34-
scalaTest % Test
35-
),
36-
Test / fork := true
34+
"org.scala-lang.modules" %%% "scala-collection-compat" % scalaCollectionCompatVersion,
35+
"org.scalatest" %%% "scalatest" % scalaTestVersion % Test,
36+
"me.shadaj" %%% "scalapy-core" % scalapyVersion % Test
37+
)
3738
)
38-
.settings(
39-
semanticdbEnabled := true,
40-
semanticdbVersion := scalafixSemanticdb.revision,
39+
.jvmSettings(
40+
crossScalaVersions := Seq(scala212, scala213, scala3),
41+
Test / fork := true,
42+
semanticdbEnabled := true,
43+
semanticdbVersion := scalafixSemanticdb.revision,
4144
scalacOptions += {
4245
CrossVersion.partialVersion(scalaVersion.value) match {
4346
case Some((2, 13)) => "-Wunused:imports"
@@ -46,9 +49,8 @@ lazy val root = project
4649
}
4750
}
4851
)
49-
.settings(
50-
sonatypeCredentialHost := "s01.oss.sonatype.org",
51-
sonatypeRepository := "https://s01.oss.sonatype.org/service/local"
52+
.nativeSettings(
53+
crossScalaVersions := Seq(scala212, scala213)
5254
)
5355

5456
lazy val docs = project
@@ -59,4 +61,4 @@ lazy val docs = project
5961
"PYTHON" -> "/usr/bin/python3"
6062
)
6163
)
62-
.dependsOn(root)
64+
.dependsOn(root.jvm)

Diff for: project/Dependencies.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import sbt._
22

33
object Dependencies {
4-
lazy val scalaCollectionCompat =
5-
"org.scala-lang.modules" %% "scala-collection-compat" % "2.7.0"
6-
lazy val scalapy = "me.shadaj" %% "scalapy-core" % "0.5.2"
7-
lazy val scalaTest = "org.scalatest" %% "scalatest" % "3.2.11"
4+
lazy val scalapyVersion = "0.5.2"
5+
lazy val scalaCollectionCompatVersion = "2.7.0"
6+
lazy val scalaTestVersion = "3.2.11"
7+
88
lazy val organizeImports = "com.github.liancheng" %% "organize-imports" % "0.6.0"
99
}

Diff for: project/plugins.sbt

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2")
2-
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")
3-
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.0")
1+
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")
2+
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0")
3+
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2")
4+
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")
5+
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.0")

Diff for: src/test/scala/ai/kien/python/PythonTest.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import org.scalatest.funsuite.AnyFunSuite
77
class PythonTest extends AnyFunSuite {
88
Python().scalapyProperties.get.foreach { case (k, v) => System.setProperty(k, v) }
99

10-
test("ScalaPy runs successfully") {
10+
test("ScalaPy actually runs") {
1111
py.Dynamic.global.list(Seq(1, 2, 3).toPythonCopy)
1212
py"'Hello from ScalaPy!'"
1313
}

0 commit comments

Comments
 (0)