0

I have a main class in the shared directory that fastOptJS::webpack manages to expose to the browser using the configuration:

scalaJSUseMainModuleInitializer := true,
mainClass in (Compile, run) := Some("path.to.package.Main")

However, I can't seem to get this executable class exposed in the JVM context even if I move the mainClass in (Compile, run) statements into the shared settings or duplicate it into the jvm settings.

Do JVM executables have to live in the jvm directory structure or can they occupy positions in the shared folder?

Any suggestions?

Here is a bare bones project that reproduces the problem: https://github.com/dragonfly-ai/mainclassbug

Ben McKenneby
  • 481
  • 4
  • 15
  • "However, I can't seem to get this executable class exposed in the JVM context" What are the symptoms? What's the error you get? – sjrd Apr 28 '19 at 05:18
  • [error] java.lang.RuntimeException: No main class detected. [error] at scala.sys.package$.error(package.scala:26) [error] (Compile / bgRun) No main class detected. – Ben McKenneby Apr 28 '19 at 17:37
  • If I duplicate the class, putting one in the js directory and one on the jvm, I can run the jvm class directly, but typing sbt run yields the error above. – Ben McKenneby Apr 28 '19 at 23:02
  • Have you tried `mainClass in Compile :=` instead of `mainClass in (Compile, run)`? – sjrd Apr 29 '19 at 07:44
  • without (Compile, run) fastOptJS::webpack suffers linker errors. I put `mainClass in Compile` in jvmSettings and `(Compile, run)` in jsSettings. Now it works in js but sbt> run still can't find the main class from JVM. Doesn't any other project out there share a main class between js and jvm? – Ben McKenneby Apr 29 '19 at 17:00
  • @sjrd Here is a bare bones project on github that demonstrates the issue: https://github.com/dragonfly-ai/mainclassbug – Ben McKenneby May 02 '19 at 02:09

0 Answers0