vmunier / sbt-web-scalajs

SBT plugin to use Scala.js along with any sbt-web server.
Apache License 2.0
194 stars 30 forks source link

Class not found exception #194

Open bwbecker opened 9 months ago

bwbecker commented 9 months ago

Continuing to debug #193, this may be related:

In an otherwise empty directory, create build.sbt, project/plugins.sbt and project/build.properties with the following contents:

# Show directory contents
bwbecker@bwbmac sbtDebug % ls -R .
build.sbt project

./project:
build.properties plugins.sbt

# empty build.sbt
bwbecker@bwbmac sbtDebug % cat build.sbt

bwbecker@bwbmac sbtDebug % cat project/build.properties 
sbt.version=1.9.8

bwbecker@bwbmac sbtDebug % cat project/plugins.sbt 
addSbtPlugin("com.vmunier"       % "sbt-web-scalajs"     % "1.1.0")
addSbtPlugin("com.typesafe.play" % "sbt-plugin"          % "2.9.1")

Run sbt:

bwbecker@bwbmac sbtDebug % sbt
[info] welcome to sbt 1.9.8 (Homebrew Java 11.0.19)
[info] loading settings for project global-plugins from plugins.sbt ...
[info] loading global plugins from /Users/bwbecker/.sbt/1.0/plugins
[info] loading settings for project sbtdebug-build from plugins.sbt ...
[info] loading project definition from /Users/bwbecker/temp/sbtDebug/project
java.lang.NoClassDefFoundError: org/webjars/WebJarExtractor$Cache
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:398)
    at sbt.internal.inc.ModuleUtilities$.getObject(ModuleUtilities.scala:24)

Changing the version of sbt-web-scalajs to 1.3.0 resolves the problem.

Alternatively, leave sbt-web-scalajs at 1.1.0 and revert addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.9.1") to 2.8.21 and add

ThisBuild / libraryDependencySchemes ++= Seq(
 "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always
)

This also works.

Conclusion: sbt-web-scalajs and sbt-plugin need to be upgraded together. Ideally, this would be checked with a warning. At least document the incompatibility.