How to install mainClass in ScalaJS build.sbt?

How to install mainClass in ScalaJS build.sbt?

I am currently installing the main class in build.sbt, like this (see last line):

enablePlugins(ScalaJSPlugin)

name := "ScalaJS-Exp"

scalaVersion := "2.11.7"

libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "0.8.1" 
libraryDependencies += "be.doeraene" %%% "scalajs-jquery" % "0.8.0" 

jsDependencies += RuntimeDOM

skip in packageJSDependencies := false

//scalaJSStage in Global := FastOptStage

// uTest settings
libraryDependencies ++= Seq(
    "com.lihaoyi" %%% "utest" % "0.3.1" % "test",
    "com.lihaoyi" %%% "scalatags" % "0.5.4",
    // Javascript libs
    "org.webjars" % "jquery" % "1.10.2",
    "org.webjars" % "jquery-ui" % "1.11.4"
)

jsDependencies ++= Seq(
    "org.webjars" % "jquery" % "1.10.2" / "jquery.js",
    "org.webjars" % "jquery-ui" % "1.11.4" / "jquery-ui.js" dependsOn "jquery.js"
)

testFrameworks += new TestFramework("utest.runner.Framework")

persistLauncher in Compile := true
persistLauncher in Test := false

mainClass := Some("htmlExp.HtmlExpApp")

When I run sbt, I get:

[warn] Multiple main classes detected.  Run 'show discoveredMainClasses' to see the list
[trace] Stack trace suppressed: run last compile:packageScalaJSLauncher for the full output.
[error] (compile:packageScalaJSLauncher) Cannot write launcher file, since there is no or multiple mainClasses
[error] Total time: 1 s, completed Jan 23, 2016 4:36:02 PM
> show discoveredMainClasses
[info] List(htmlExp.HtmlExpApp, tutorial.webapp.MyApp)
[success] Total time: 0 s, completed Jan 23, 2016 4:36:13 PM
>

This does not work if I remove the mainClass parameter from the build.sbt file. The error message is the same as or without the mainClass parameter.

In the sbt hint, when I try to run runMain htmlExp.HtmlExpApp, it works and runs the main class.

How can I install mainClass in the build.sbt file, or is it that ScalaJSPlugin does not support this parameter?

+4
source share
1 answer

mainClass must be set for each configuration:

mainClass in Compile := Some("htmlExp.HtmlExpApp")

mainClass := ???, mainClass . , mainClass . . - mainClass .

, Scala.js. JVM (, . ).

+4

Source: https://habr.com/ru/post/1625645/


All Articles