scala-js/scala-js-dom

Resolver for 0.6

mathieuleclaire opened this issue · 12 comments

Hi,
the resolver seems to have changed since the 0.5 version.
What resolver is supposed to be used for 0.6 version ?

Thanks for helping !
Mathieu

sjrd commented

No resolver is supposed to be needed. Well, to be precise, the required resolver is added by scalaJSSettings. Perhaps you forgot to use %%% instead of %%?

I had never see that syntax before.
Acutally I tried it with 3 "%" but this operator is not recognized (tested with 0.13.1, 0.13.2 and 0.13.5). I get the error:

value %%% is not a member of String
[error]         "org.scala-lang.modules.scalajs" %%% "scalajs-dom" % "0.6",
[error]                                          ^
[error] one error found
sjrd commented

I had never see that syntax before.

You wouldn't have. It is Scala.js-specific, and was introduced with Scala.js 0.5.0, so it's brand new. You need the Scala.js sbt plugin for it to be available. Can you confirm that you have the following line in your project/build.sbt (or project/plugins.sbt or however you choose to call it):

addSbtPlugin("org.scala-lang.modules.scalajs" % "scalajs-sbt-plugin" % "0.5.0")

?

More generally, you might want to follow the steps in the tutorial to get you started with Scala.js 0.5. (Any 0.13.x version of sbt should work.)

If you still have an issue, can you elaborate a bit on your config? In particular the contents of your build.sbt and project/build.sbt would greatly help to identify the issue.

It is actually clearer ! It was not so straighforward in a multiproject application. Anyway, now it works fine. Thanks for helping. If you are interested in, have a look to my scaladget library which intends to use scala.js to provide higher level lib for building html pages in pure scala (https://github.com/mathieuleclaire/scaladget).

I have a comment about the new 0.5 version:
The library I just started (scaladget) relies on scala.js. When I use it in an other project (in the examples project of scaladget for instance), I need to use "%%%" to add my lib as dependency

libraryDependencies += "fr.iscpif" %%% "scaladget" % "0.1.0-SNAPSHOT"

It implies that I need to keep a dependency on the scala.js library in my example project. It would be nicer and clearer to have only a dependency on my lib for the final user of the scaladget lib. Is there a trick to bypass the scala.js dependency (as it was the case in the 0.4 version) ?

sjrd commented

I don't understand. If your project is a Scala.js project, then by necessity any project depending on it is also a Scala.js project. What trick are you talking about in 0.4?

My lib is a Scala.js project, but a project depending on my lib should only depends on my lib and not on scala.js. Here is the build of an example project using my lib:

import sbt._
import Keys._
import fr.iscpif.jsmanager.JSManagerPlugin._

import scala.scalajs.sbtplugin.ScalaJSPlugin._

object ExampleBuild extends Build {
  val Organization = "fr.iscpif"
  val Name = "Scaladget Example"
  val Version = "0.1.0-SNAPSHOT"
  val ScalaVersion = "2.10.4"

  lazy val scaladgetExample = Project("examples",
    file("examples"),
    settings = Defaults.defaultSettings ++ jsManagerSettings ++ Seq(
      resolvers += Resolver.sonatypeRepo("snapshots"),
      libraryDependencies += "fr.iscpif" %%% "scaladget" % "0.1.0-SNAPSHOT",
      jsCall := "Form().run();"
      //outputPath := "/tmp"
    )
  )
}

The only solution I see is to exhibit a %%% function in my plugin, which calls the %%% scala.js function.
I realize that this thread is more a scala-js issue than a scala-js-dom one ! Sorry for that.

sjrd commented

Ah, your project is a compiler plugin itself! That wasn't clear at all from your formulation of "my library". Then, yes, assuming jsManagerSettings contain scalaJSSettings, it's a valid setup. And then, yes, the solution for you is to provide %%% from your plugin. This is easily done by mixing in impl.DependencyBuilders:

object MyPlugin extends Plugin with scala.scalajs.sbtplugin.impl.DependencyBuilders {
  ...
}

although that makes your source dependent on the particular implementation of impl, which is not recommended.

Actually there are both a plugin (called jsManager) and a project (called scaladget). The examples project depends on both.

Well, mixing with DependencyBuilders does not fix it. The %%% is viewed as a String and the implicit converter toScalaJSGroupID is not invoked

I was actually mixing impl.DependencyBuilders instead of scala.scalajs.sbtplugin.impl.DependencyBuilders. It's now works fine. Thanks !

Closing this isnce you seem to have figured it out =)