Skip to content

Conversation

maxandersen
Copy link
Contributor

@maxandersen maxandersen commented Jul 28, 2025

Fixes #1952

Context

Adds support for using jbang to define extensions.

extensions:
  github-summary:
    jbang: misc/jreleaser-extension/githubjobsummary.java

Checklist

@CLAassistant
Copy link

CLAassistant commented Jul 28, 2025

CLA assistant check
All committers have signed the CLA.

@aalmiray aalmiray added the enhancement New feature or request label Jul 28, 2025
@@ -34,6 +34,8 @@ public interface Extension extends Domain, EnabledAware {

String getDirectory();

String getJBang();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha - i'm wondering if it would make sense to make room for jbang arguments ?

i.e. technically you can affect/modify the build with jbang arguments like jbang -Dkey=value --compile-options etc.

maybe that should be a jbang-args flag ?

jbang: 
   - scriptref: myext.java
   - args: ...

is an alternative but would be sad to loose the simplicity of jbang: myext.java ...or do you allow maps|string option in jreleaser elsewhere?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, there's a map in environment: for extra properties but it may not necessarily be available at the time extensions are loaded.

Also would prefer if the additional args were set closer to where they are needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would have to decide how to do it as changing the type after the next release would constitute a breaking change.

What other elements may be required besides script and args?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar as https://github.com/jbangdev/jbang-gradle-plugin and maven ones...

the main ones are script, jbang-args and trust (although trust we could consider auto add/remove in calls but feels risky ;)

Copy link
Member

@aalmiray aalmiray Jul 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so we need 4 properties:

  • script
  • args
  • jbangArgs
  • trusts

To keep compatibility with names found in other UIs. This means adding a pair of classes in model-api and model-impl following the patterns for other Domain subtypes. The gradle DSL would require similar changes, which I can take care of.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

args itself does not make sense here - as jreleaser does its own init and skips any main method calling.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version should also be specified otherwise the default bundled version will always be chosen.

I can refactor the code later after merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but thats the same for maven ?

@@ -65,6 +66,11 @@ public String getDirectory() {
return directory;
}

@Override
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the serialVersionUID at

private static final long serialVersionUID = 8235578876272898842L;

private static final long serialVersionUID = -8554317090414988356L;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've bumped +1 but also //TODO'ed as i dont have a serial version generator handy

@aalmiray
Copy link
Member

Build failed due to checkstyle

 Error: eckstyle] [ERROR] /home/runner/work/jreleaser/jreleaser/sdks/jreleaser-tool-java-sdk/src/main/java/org/jreleaser/sdk/tool/AbstractTool.java:23:8: Unused import - org.jreleaser.sdk.command.Command.Result. [UnusedImports]

@maxandersen
Copy link
Contributor Author

I pushed update that adds recursive scanning of .jar in extension directories + use jbang export portable instead of jbang export local.

And it works...BUT you get:

out/jreleaser/extensions/github-summary/
├── github-summary.jar
└── lib
├── autolink-0.10.0.jar
├── bcpg-jdk18on-1.80.jar
├── bcprov-jdk18on-1.80.jar
├── commonmark-0.21.0.jar
├── commonmark-ext-autolink-0.21.0.jar
├── commons-codec-1.18.0.jar
├── commons-compress-1.27.1.jar
├── commons-io-2.16.1.jar
├── commons-lang3-3.16.0.jar
├── compiler-0.9.14.jar
├── jackson-annotations-2.19.0.jar
├── jackson-core-2.19.0.jar
├── jackson-databind-2.19.0.jar
├── jcl-over-slf4j-2.0.17.jar
├── jipsy-annotations-1.2.0.jar
├── jipsy-processor-1.2.0.jar
├── jreleaser-logger-api-1.18.0.jar
├── jreleaser-model-api-1.18.0.jar
├── jreleaser-resource-bundle-1.18.0.jar
├── jreleaser-utils-1.18.0.jar
├── slf4j-api-2.0.17.jar
├── xz-1.10.jar
└── zstd-jni-1.5.7-2.jar

which seems wasteful :)

I see two things:

  • update jreleaser mechanism to be able to refer to list of jars from the maven repository - jbang can give the list in a json to parse....that avoids copying the same jar around N times and taking up uneccsary space.
  • but even with that; even though above works where my ext use 1.18 and jreleaser is 1.20; i could imagine there being conflicts where export local would be better?

@maxandersen maxandersen marked this pull request as ready for review July 28, 2025 22:16
@maxandersen
Copy link
Contributor Author

I made jreleaser/jreleaser.github.io#91 as suggestion for docs.

@aalmiray aalmiray added this to the v1.20.0 milestone Jul 29, 2025
@aalmiray aalmiray merged commit a3d96cb into jreleaser:main Jul 29, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[extensions] Support loading extensions built with JBang
3 participants