Using scala.js to compile only (and not override run) in SBT -


i'm trying use scalajs compile scala sources javascript , not modify else sbt environment, don't want override default behavior of "run" sbt command.

currently i've got build.sbt looks like:

import scalajskeys._  scalajssettings  name := "foo"  organization := "com.example"  scalaversion := "2.11.4"  compile <<= (compile in compile) dependson (fastoptjs in compile)  crosstarget in (fastoptjs in compile) := ((classdirectory in compile).value / "public" / "js")  librarydependencies ++= { val sprayversion = "1.3.2" val akkaversion = "2.3.7" seq(     "io.spray"            %%  "spray-can"     % sprayversion,     "io.spray"            %%  "spray-routing" % sprayversion,     "io.spray"            %%  "spray-servlet" % sprayversion,     "io.spray"            %%  "spray-testkit" % sprayversion  % "test",     "com.typesafe.akka"   %%  "akka-actor"    % akkaversion,     "com.typesafe.akka"   %%  "akka-testkit"  % akkaversion   % "test",     "org.specs2"          %%  "specs2-core"   % "2.3.11" % "test",     "javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",     "org.scala-lang.modules.scalajs" %%% "scalajs-jquery" % "0.6" )} 

which compiles both javascript , scala fine, problem breaks existing "run" command want run plain old scala using same discovery default sbt. project simple don't want go down multi-project route (as play-with-scalajs-example). guess need remove scalajssettings don't know how access fastoptjs target can attach dependency compile after doing so.

you must not this. put scalajssettings in project, sources compiled scala.js compiler plugin.

this indeed produce .class files, however, contain things basic scala compiler not emit , can therefore lead binary incompatibility issues or unexpected behavior (see this post).

instead, use multi-project build:

import scalajskeys._  organization := "com.example" scalaversion := "2.11.4"  val sprayversion = "1.3.2" val akkaversion = "2.3.7"  lazy val foo = project.   settings(     name := "foo",     compile <<= (compile in compile) dependson (fastoptjs in compile in bar),     crosstarget in (fastoptjs in compile in bar) :=       ((classdirectory in compile).value / "public" / "js"),     librarydependencies ++= seq(       "io.spray"            %%  "spray-can"     % sprayversion,       "io.spray"            %%  "spray-routing" % sprayversion,       "io.spray"            %%  "spray-servlet" % sprayversion,       "io.spray"            %%  "spray-testkit" % sprayversion  % "test",       "com.typesafe.akka"   %%  "akka-actor"    % akkaversion,       "com.typesafe.akka"   %%  "akka-testkit"  % akkaversion   % "test",       "org.specs2"          %%  "specs2-core"   % "2.3.11" % "test",       "javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided"     )   )   lazy val bar = project.   settings(scalajssettings: _*).   settings(     name := "bar",     librarydependencies += "org.scala-lang.modules.scalajs" %%% "scalajs-jquery" % "0.6",   ) 

this resolves issue run command.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -