diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c288a3e..c04995a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: with: python-version: ${{ matrix.python }} - name: Test - run: sbtn +test + run: sbtn +root/test shell: bash publish: runs-on: ubuntu-20.04 diff --git a/build.sbt b/build.sbt index 63eb7a3..ab56a7e 100644 --- a/build.sbt +++ b/build.sbt @@ -23,21 +23,27 @@ lazy val scala3 = "3.0.2" ThisBuild / scalaVersion := scala213 ThisBuild / scalafixDependencies += organizeImports -lazy val root = project +lazy val root = crossProject(JVMPlatform, NativePlatform) + .withoutSuffixFor(JVMPlatform) + .crossType(CrossType.Pure) .in(file(".")) .settings( - name := "Python Native Libs", - crossScalaVersions := Seq(scala212, scala213, scala3), + name := "Python Native Libs", libraryDependencies ++= Seq( - scalaCollectionCompat, - scalapy % Test, - scalaTest % Test - ), - Test / fork := true + "org.scala-lang.modules" %%% "scala-collection-compat" % scalaCollectionCompatVersion, + "org.scalatest" %%% "scalatest" % scalaTestVersion % Test, + "me.shadaj" %%% "scalapy-core" % scalapyVersion % Test + ) ) .settings( - semanticdbEnabled := true, - semanticdbVersion := scalafixSemanticdb.revision, + sonatypeCredentialHost := "s01.oss.sonatype.org", + sonatypeRepository := "https://s01.oss.sonatype.org/service/local" + ) + .jvmSettings( + crossScalaVersions := Seq(scala212, scala213, scala3), + Test / fork := true, + semanticdbEnabled := true, + semanticdbVersion := scalafixSemanticdb.revision, scalacOptions += { CrossVersion.partialVersion(scalaVersion.value) match { case Some((2, 13)) => "-Wunused:imports" @@ -46,9 +52,8 @@ lazy val root = project } } ) - .settings( - sonatypeCredentialHost := "s01.oss.sonatype.org", - sonatypeRepository := "https://s01.oss.sonatype.org/service/local" + .nativeSettings( + crossScalaVersions := Seq(scala212, scala213) ) lazy val docs = project @@ -59,4 +64,4 @@ lazy val docs = project "PYTHON" -> "/usr/bin/python3" ) ) - .dependsOn(root) + .dependsOn(root.jvm) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index c1ff9f5..2403fdc 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -1,9 +1,9 @@ import sbt._ object Dependencies { - lazy val scalaCollectionCompat = - "org.scala-lang.modules" %% "scala-collection-compat" % "2.7.0" - lazy val scalapy = "me.shadaj" %% "scalapy-core" % "0.5.2" - lazy val scalaTest = "org.scalatest" %% "scalatest" % "3.2.11" + lazy val scalapyVersion = "0.5.2" + lazy val scalaCollectionCompatVersion = "2.5.0" + lazy val scalaTestVersion = "3.2.10" + lazy val organizeImports = "com.github.liancheng" %% "organize-imports" % "0.6.0" } diff --git a/project/plugins.sbt b/project/plugins.sbt index 9412367..7444726 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,5 @@ -addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2") -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.0") +addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0") +addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.0") diff --git a/src/test/scala/ai/kien/python/PythonTest.scala b/src/test/scala/ai/kien/python/PythonTest.scala index 4c46181..28d4990 100644 --- a/src/test/scala/ai/kien/python/PythonTest.scala +++ b/src/test/scala/ai/kien/python/PythonTest.scala @@ -7,7 +7,7 @@ import org.scalatest.funsuite.AnyFunSuite class PythonTest extends AnyFunSuite { Python().scalapyProperties.get.foreach { case (k, v) => System.setProperty(k, v) } - test("ScalaPy runs successfully") { + test("ScalaPy actually runs") { py.Dynamic.global.list(Seq(1, 2, 3).toPythonCopy) py"'Hello from ScalaPy!'" }