sbt / sbt-native-packager

sbt Native Packager
https://sbt-native-packager.readthedocs.io/en/stable/
BSD 2-Clause "Simplified" License
1.59k stars 439 forks source link

Workarounds for "input too long" problem do not work as expected #1466

Open bobismijnnaam opened 2 years ago

bobismijnnaam commented 2 years ago

Expected behaviour

Using enablePlugins(LauncherJarPlugin) or enablePlugins(ClasspathJarPlugin) should result in a package that runs.

Actual behaviour

When either of enablePlugins(LauncherJarPlugin) or enablePlugins(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

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.

muuki88 commented 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.

bobismijnnaam commented 2 years ago

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).

ArmborstL commented 2 years ago

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 😄

bobismijnnaam commented 2 years ago

I made a minimal version of our big project that exhibits the problem:

vercors_stripped_test.zip

Reproduction steps:

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.