3

If I needed to use the stable release version, I would have my project/plugins.sbt as below:

addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0")

I am trying to use a specific version (a PR to be precise) of ScalaNative for my project.

Here is my build.sbt

scalaVersion := "2.13.4"


// Set to false or remove if you want to show stubs as linking errors
nativeLinkStubs := true

enablePlugins(ScalaNativePlugin)

And this is my project/plugins.sbt

lazy val root = (project in file(".")).dependsOn(scalaNativePlugin)
lazy val scalaNativePlugin = RootProject(uri("https://github.com/scala-native/scala-native.git#v0.4.0"))

When I run sbt it fails with the following error log.

[info] welcome to sbt 1.4.6 (Oracle Corporation Java 1.8.0_292)
[info] loading global plugins from /home/sadique/.sbt/1.0/plugins
[info] loading settings for project root from plugins.sbt ...
[info] loading settings for project scala-native-build from build.sbt ...
[info] loading project definition from /home/sadique/.sbt/1.0/staging/5c4ed83a83573e9369a0/scala-native/project
[info] loading settings for project scala-native from build.sbt ...
[info] resolving key references (24414 settings) ...
[info] loading project definition from /home/sadique/Programming/scala/scala-native-template/sn-test-custom/project
/home/sadique/Programming/scala/scala-native-template/sn-test-custom/build.sbt:6: error: not found: value ScalaNativePlugin
enablePlugins(ScalaNativePlugin)
              ^
[error] Type error in expression
[warn] Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? (default: r)

I have tried with both capital and small S in scalaNativePlugin for the variable name in plugins.sbt.

What am I doing wrong? What is the correct way to do this?

1 Answers1

4

As a workaround, I might suggest building Scala Native locally, just fork github project, rebase to expected branch/PR, run sbt and use publishLocal command, if you want to get Scala 2.11 or 2.13 artifacts remember to switch used Scala version using ++SCALA_VERSION, since sbt assumes Scala 2.12.x as default one. Version of the current build can be found in nir/src/main/scala/scala/scalanative/nir/Versions.scala, currently it's 0.4.1-SNAPSHOT. You can use it in your project after creating local artifacts or adjust it.

  • Thanks. How/where do i specify the SCALA_VERSION ? I tried running `publishLocal SCALA_VERSION=2.13.4` but that promptly failed. Is there a file i need to edit somewhere? – theFakeSheikS Jul 04 '21 at 16:35
  • `+publishLocal` seemed to do the job. It publishes for all supported versions of scala (2.11, 2.12, 2.13). I could also edit the scalaVersion variable but `+publishLocal` seems like a cleaner solution. – theFakeSheikS Jul 05 '21 at 04:38