Can't share main class between JS and JVM builds.
dragonfly-ai opened this issue · 1 comments
dragonfly-ai commented
Please consider this project on github:
https://github.com/dragonfly-ai/mainclassbug
This bare bones project reproduces an error involving the main class declared with mainClass in (Compile, run) := Some("com.example.Main")
and .jsSettings(scalaJSUseMainModuleInitializer := true)
which does not express itself in the JVM context.
Specifically, although the main method finds its way to the output of fastOptJS, typing sbt run
fails with the following error message:
[error] java.lang.RuntimeException: No main class detected.
[error] at scala.sys.package$.error(package.scala:26)
[error] (Compile / bgRun) No main class detected.
sjrd commented
You have to use mainclassbugJS/run
and/or mainclassbugJVM/run
. Just run
tries to run the implicitly created root project, which has no code and hence no main class.