1

I have an SBT plugin which will auto-generate some Scala.js code just before compile time. This code depends on a library which I would like to automatically include when the plugin is enabled.

This compiles and runs, but does not get the Scala.js version of the library:

import sbt._
import Keys.libraryDependencies

object MyPlugin extends AutoPlugin {
  object autoImport {
    lazy val baseSettings: Seq[Def.Setting[_]] = Seq(
      libraryDependencies += "my.lib" %% "library" % "0.1.0"
    )
  }

  import autoImport._

  override lazy val projectSettings = baseSettings
}

I when I try to use "my.lib" %%% "library" % "0.1.0", I get:

value %%% is not a member of String

I feel like I'm probably missing an import, but I can't find where this is supposed to be defined.

Thomas
  • 871
  • 2
  • 8
  • 21
  • Because there is nothing like `%%%`. There are only `%%` and `%`. – sarveshseri Sep 25 '20 at 04:36
  • The scala.js documentation seems pretty clear to me. Do you know something I don't? https://www.scala-js.org/doc/project/dependencies.html – Thomas Sep 25 '20 at 04:38
  • I meant that you are using only `%%` and `%` in you code - `libraryDependencies += "my.lib" %% "library" % "0.1.0"`. Sorry to misunderstand your questions. – sarveshseri Sep 25 '20 at 04:39
  • Because when I replace that line with `libraryDependencies += "my.lib" %% "library" % "0.1.0"` I get an error. I want to know what I need to import to make `%%%` work correctly. – Thomas Sep 25 '20 at 04:40

2 Answers2

3

%%% is defined by the sbt-platformdeps plugin.

Unless your sbt plugin already depends on sbt-scalajs, you'll need to add a dependency to it in your plugin project's settings:

addSbtPlugin("org.portable-scala" % "sbt-platform-deps" % "1.0.0")

The following import will bring it in scope:

import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._
sjrd
  • 21,805
  • 2
  • 61
  • 91
  • Thank you for you very concise and informative explanation. I guess I was looking for it in the Scala.js code because I didn't realize it's a more general purpose syntax. – Thomas Sep 26 '20 at 13:07
-1

addSbtPlugin("com.lightbend.lagom" % "lagom-sbt-plugin" % "X.Y.Z") // replace 'X.Y.Z' with your preferred version (e.g. '1.2.0-RC2').

You can refer to this one https://www.lagomframework.com/documentation/1.6.x/java/LagomBuild.html

Samual
  • 67
  • 9