Open bobismijnnaam opened 2 years ago
Thanks a lot @bobismijnnaam for the detailed report.
This surely sounds like a bug. Do you have the time to create a minimal example reproducing this?
My initial guess would be that there are multiple main classes, but not sure if this explains this.
Here is our build.sbt: https://github.com/utwente-fmt/vercors/blob/dev/build.sbt
I think we have only one main class but of course maybe our settings are wrong. I have vacation this week but I'll try to make a repro when I get back (or maybe one of my team members can have a look, but I expect them to be busy as well).
FWIW, I think that there are indeed multiple main classes, as we include other git repositories as dependencies, which have their own main method. The build.sbt even mentions multiple mains, and tries to handle them in some way: https://github.com/utwente-fmt/vercors/blob/97c49d6dc1097ded47a5ed53143695ace6904865/build.sbt#L153 I spent a little time trying to reduce the example. But as a newbie to sbt, I didn't get far, and I think I'll wait for Bob to get back 😄
I made a minimal version of our big project that exhibits the problem:
Reproduction steps:
sbt shell
in the root project folder with the build.sbt
clean; Univeral / packageZipTarball
target / universal
, there should now be a .tgz
file. Unzip that, cd
into it, and run the command ./bin/vercors --help
. This should print the error cannot find class vct.main.Main
.EDIT: Looks like the problem is that we have spaces in the organization in our build.sbt... So the short term fix for us is clear (i.e. remove spaces from our organization), not sure how you want to handle this on your side.
Expected behaviour
Using
enablePlugins(LauncherJarPlugin)
orenablePlugins(ClasspathJarPlugin)
should result in a package that runs.Actual behaviour
When either of
enablePlugins(LauncherJarPlugin)
orenablePlugins(ClasspathJarPlugin)
is used, when running the generated package, an error is printed: "class vct.main.Main not found". (vct.main.Main is the main class of our package)Information
rpm --version
): I used the file manager's built-in "extract here"What's strange is that if I run the package with a custom java command in the terminal, e.g.:
$ java -cp 'lib/*:res vct.main.Main --help
As expected, it prints the help message. So all classes needed for running our package are in the unzipped package. But somehow the run script/jar files that sbt-native-packager generates have trouble finding the class files.
Currently we are using the workaround of:
scriptClasspath := Seq("*", "../res")
, which does result in a package that runs as expected, but we'd rather use one of the aforementioned plugins for clarity and stability.I am aware of https://sbt-native-packager.readthedocs.io/en/latest/recipes/longclasspath.html, #1327, and #1071, but I think I have tried all three options (of which the third worked, the
Seq("*")
approach). I did not apply any other changed to my build.sbt except adding the "enablePlugins" statements; please let me know if there is more intricate setup required to make these plugins function.