jbang icon indicating copy to clipboard operation
jbang copied to clipboard

"--deps" options overrides alias defined dependencies instead of adding extra dependencies

Open ivangsa opened this issue 5 months ago • 2 comments

Describe the bug

"--deps" options overrides alias defined dependencies instead of adding extra dependencies

This is confusing because documentation states they are additional dependencies:

--deps=<dependencies>
Add additional dependencies (Use commas to separate them).

https://www.jbang.dev/documentation/guide/latest/cli/jbang-run.html

Is this the expected behaviour? or should it append --deps as extra classpath entries?

To Reproduce

If I run the following alias it will print the full list of certain plugins found on the classpath

$ jbang snapshots@zenwave360/zenwave-sdk -h
Usage: <main class> [-f] [-h[=<helpFormat>]] [-p[=<pluginClass>]]
                    [<String=Object>...]
      [<String=Object>...]
  -f, --force                Force overwrite
  -h, --help[=<helpFormat>]  Help with output format
  -p, --plugin[=<pluginClass>]
                             Plugin Class or short-code
INFO Reflections - Reflections took 1673 ms to scan 64 urls, producing 7527 keys and 56254 values
ZW> SDK (2.1.0-SNAPSHOT)

Available plugins:

io.zenwave360.sdk.plugins.BackendApplicationDefaultPlugin: Generates a full backend application using the provided 'layout' property (2.1.0-SNAPSHOT)
io.zenwave360.sdk.plugins.SpringCloudStreams3AdaptersPlugin: Generates Spring Cloud Streams Consumers from AsyncAPI definitions. (2.1.0-SNAPSHOT)
io.zenwave360.sdk.plugins.JDLToAsyncAPIPlugin: Generates a full AsyncAPI definitions for CRUD operations from JDL models (2.1.0-SNAPSHOT)
io.zenwave360.sdk.plugins.ZdlToJsonPlugin: Prints to StdOut ZDL Model as JSON (2.1.0-SNAPSHOT)
io.zenwave360.sdk.plugins.SpringWebTestClientPlugin: Generates test for SpringMVC or Spring WebFlux using WebTestClient based on OpenAPI specification. (2.1.0-SNAPSHOT)
io.zenwave360.sdk.plugins.AsyncApiJsonSchema2PojoPlugin: Generate Plain Old Java Objects from OpenAPI/AsyncAPI schemas or full JSON-Schema files. (2.1.0-SNAPSHOT)
io.zenwave360.sdk.plugins.OpenAPIControllersPlugin: Generates implementations based on ZDL models and OpenAPI definitions SpringMVC generated OpenAPI interfaces. (2.1.0-SNAPSHOT)    
io.zenwave360.sdk.plugins.OpenAPIToJDLPlugin: Generates JDL model from OpenAPI schemas (2.1.0-SNAPSHOT)
io.zenwave360.sdk.plugins.SpringCloudStreams3Plugin: Generates strongly typed SpringCloudStreams3 producer/consumer classes for AsyncAPI (2.1.0-SNAPSHOT)
io.zenwave360.sdk.plugins.OpenAPIKaratePlugin: Generates test for KarateDSL based on OpenAPI specification. (2.1.0-SNAPSHOT)
io.zenwave360.sdk.plugins.ZDLToOpenAPIPlugin: Generates a draft OpenAPI definitions from your ZDL entities and services. (2.1.0-SNAPSHOT)
io.zenwave360.sdk.plugins.ZdlToMarkdownPlugin: Generates Markdown glossary from Zdl Models (2.1.0-SNAPSHOT)
io.zenwave360.sdk.plugins.ZDLToAsyncAPIPlugin: Generates a draft AsyncAPI file with events from your ZDL services. (2.1.0-SNAPSHOT)

If I add --deps parameter it overrides alias defined dependencies, and uses only the ones passed as --deps

$ jbang --deps=io.zenwave360.sdk.plugins:backend-application-kotlin:2.1.0-SNAPSHOT snapshots@zenwave360/zenwave-sdk -h
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Usage: <main class> [-f] [-h[=<helpFormat>]] [-p[=<pluginClass>]]
                    [<String=Object>...]
      [<String=Object>...]
  -f, --force                Force overwrite
  -h, --help[=<helpFormat>]  Help with output format
  -p, --plugin[=<pluginClass>]
                             Plugin Class or short-code
ZW> SDK (2.1.0-SNAPSHOT)

Available plugins:

io.zenwave360.sdk.plugins.BackendApplicationDefaultPlugin: Generates a full backend application using the provided 'layout' property (2.1.0-SNAPSHOT)
io.zenwave360.sdk.plugins.ZdlToJsonPlugin: Prints to StdOut ZDL Model as JSON (2.1.0-SNAPSHOT)
io.zenwave360.sdk.plugins.OpenAPIControllersPlugin: Generates implementations based on ZDL models and OpenAPI definitions SpringMVC generated OpenAPI interfaces. (2.1.0-SNAPSHOT)    

Expected behavior --deps=<dependencies> should be appended (or prepended to take higher precedence) to the actual alias classpath as extra dependencies

JBang version

Additional context

ivangsa avatar Jun 11 '25 09:06 ivangsa

This is somewhat similar to #1910 . It's always difficult to decide what to do in these cases. Whatever decision you make you're going to enable some use-cases and make others impossible. On top of that we'd have to take into account if changing this now wouldn't break existing scripts.

We must think about this carefully before we can say yay or nay.

quintesse avatar Jun 11 '25 12:06 quintesse

Maybe we could have --extra-deps and clearly state that those would be prepended/appended to existing deps.. This wouldn't break existing scripts

We must think about this carefully before we can say yay or nay.

Yep, totally get it..

ivangsa avatar Jun 11 '25 13:06 ivangsa

Hi, I managed this on my side using an app parameter and fetching the extra dependencies myself (using jbang library)

ivangsa avatar Nov 24 '25 07:11 ivangsa