jbangdev / jbang

Unleash the power of Java - JBang Lets Students, Educators and Professional Developers create, edit and run self-contained source-only Java programs with unprecedented ease.
https://jbang.dev
MIT License
1.36k stars 153 forks source link

Support for running java -jar #1812

Open dsyer opened 1 week ago

dsyer commented 1 week ago

As far as I can tell jbang always runs with -classpath, even if the resolved "script" is an executable jar. The logical thing to do would seem to be to spot (or have the user specify) the fact that it is executable, and just ignore the dependencies or not bother resolving them. Instead we get a long classpath with the executable jar at the start. Is there a reason for that?

Example from the TestRun test cases:

java -classpath /home/dsyer/.m2/repository/io/quarkus/quarkus-cli/1.9.0.Final/quarkus-cli-1.9.0.Final-runner.jar:...<long_list_of_dependencies>:/home/dsyer/.gradle/caches/modules-2/files-2.1/org.jboss.logging/jboss-logging/3.3.2.Final/3789d00e859632e6c6206adc0c71625559e6e3b0/jboss-logging-3.3.2.Final.jar io.quarkus.runner.GeneratedMain

where

java -jar /home/dsyer/.m2/repository/io/quarkus/quarkus-cli/1.9.0.Final/quarkus-cli-1.9.0.Final-runner.jar

would have been just fine (and less prone to mismatched dependency resolution expectations between jbang and the jar author).

dsyer commented 1 week ago

Duplicates #1778?