I'm packaging jars from generated source code with an sbt-plugin and the jars are fine and on the classpath.
Now I have two identical minimal projects targeting Scala 2.13 and 3.3. With 2.13 I can run sbt clean Test/compile
but with 3.3 it gives me this error:
Could not find null in Some(.../test-project-3/lib/molecule-test-project-3.jar)
-- [E006] Not Found Error: .../test-project-3/src/test/scala/app/Connection.scala:14:23
14 | val schema: Schema = PersonSchema
| ^^^^^^^^^^^^
| Not found: PersonSchema
I clean
to make sure that the test code picks up the code in the generated jars only (which works fine with 2.13).
I thought then that it might have to do with som binary issues and therefore tried running with JDK versions 8, 11 and 20, but that didn't make a difference.
The following commands compiles the two projects (and the last one fails):
git clone https://github.com/scalamolecule/sbt-molecule.git
cd sbt-molecule/test-project-2
sbt clean compile -Dmolecule=true
sbt clean Test/compile
cd ../test-project-3
sbt clean compile -Dmolecule=true
sbt clean Test/compile
(the -Dmolecule=true
flag makes the plugin generate jars)
Thankful for any ideas of what this might be about!
Build file for 3.3 version:
name := "sbt-molecule-test-project"
version := "1.8.1-SNAPSHOT"
organization := "org.scalamolecule"
scalaVersion := "3.3.3"
libraryDependencies ++= Seq(
"com.lihaoyi" %% "utest" % "0.8.3",
"org.scalamolecule" %% "molecule-sql-h2" % "0.9.0",
)
testFrameworks += new TestFramework("utest.runner.Framework")
Test / parallelExecution := false
// Molecule
enablePlugins(MoleculePlugin)
// Generate Molecule boilerplate code with `sbt clean compile -Dmolecule=true`
moleculePluginActive := sys.props.get("molecule").contains("true")
// tells plugin where to look for definitions of code to be generated
moleculeDataModelPaths := Seq("app")
// Doesn't make a difference
//Test / fork := true
build.sbt
file?Connection.scala
a generated file? Where isPersonSchema
supposed to be defined? Did you open the JAR file to see what's in it?Connection
is a test file andPersonSchema
is generated and is present in the jar. So the jar and the generation process itself seems fine. The problem arise when the generated source files are cleaned away and sbt compiles the test code, then it doesn't find (or can't use) the jar.