I have the following build.sbt file:
lazy val shared = (project in file("shared")) .
settings (moduleName := "x-shared") .
...
lazy val service = (project in file ("service")) .
settings (moduleName := "x-api") .
dependsOn (shared % "compile->compile;test->test", job % "compile->compile;test->test") .
aggregate (shared, joob) .
...
lazy val job = (project in file("job") dependsOn (shared % "compile->compile;test->test")) .
settings (moduleName := "x-job") .
...
The service submodule requires both shared and job modules. The shared project is basically a set of classes used by all the modules. Both job and service are different applications, but we have an endpoint on the service, that requires to start the job application.
The problem is that on runtime, we get the following error when trying to reference the job module classes:
java.lang.NoClassDefFoundError: com/earnest/ingestor/models/Pipeline$
But we are able to reference the shared module without any problem.
The folder structure of the project is the following:
./root
./service
./shared
./job
One thing I notice is that the jar file generated for the job module, does not get copied on the lib folders on the service module, in difference with the shared jar file:
service/target/universal/stage/lib dir contains both:
com.earnest.x-api-localdev.9288.jar
com.earnest.x-shared-localdev.9288.jar
But the job jar gets populated to the jobs module:
job/target/universal/stage/lib contains:
com.earnest.x-job-localdev.9288.jar
I'm pretty new to sbt builds, so not sure if might be missing some piece during the build which is done via the sbt clean command. We are using the sbt-native-package plugin. I'm not sure what other information might be useful to share so I extracted the build.sbt key points, thanks for the help in advance.
sbt plugins:
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.11")
Update 1
The application is being launch from a launcher.jar using what it seems to be the LauncherJarPlugin from the build.sbt file. One thing I've notice is that the launcher.jar does not contain the com.earnest.x-job-localdev.9288.jar
in the ClassPath on META_INF/MANIFEST.MF
I was able to resolve my issue with setting up the service module adding job % "compile->compile;test->test"
The whole block looks like:
lazy val service = (project in file ("service")) .
settings (moduleName := "x-api") .
dependsOn (shared % "compile->compile;test->test", job % "compile->compile;runtime->runtime;test->test") .
aggregate (shared, job) .
...