Build Integration [EXPERIMENTAL]

While jbang prepares and builds the underlying jar used for launch there is since v0.40 (for now) experimental API allowing user included dependencies to influence the generated jar and possible native image.

An example use case enabled by this is to have full Quarkus integration, jbang will have Quarkus participate to perform its build time optimizations rather than doing it at runtime every time. You can even do jbang (since Quarkus 1.11+) run in devmode and have automatic build happen without having to restart.

It works as following:

Before the jar is created jbang will scan the classpath for META-INF/jbang-integration.list. Any classes listed in this file will be loaded and jbang will expect and call the following method on these classes:

public class JBangIntegrationExample {

    * @param temporaryJar temporary JAR file path
    * @param pomFile location of pom.xml representing the projects dependencies
    * @param repositories list of the used repositories
    * @param dependencies list of GAV to Path of artifact/classpath dependencies
    * @param comments comments from the source file
    * @param nativeImage true if --native been requested
    * @return Map<String, Object> map of returns; special keys are "native-image" which is a and "files" to
    *          return native-image to be run and list of files to get written to the output directory.
    public static Map<String, Object> postBuild(Path temporaryJar,
                                                Path pomFile,
                                                List<Map.Entry<String, String>> repositories,
                                                List<Map.Entry<String, Path>> dependencies,
                                                List<String> comments,
                                                boolean nativeImage) {

Since version 0.92.0 the full path to the JBang script can be acquired by querying the jbang.source system property - System.getProperty("jbang.source")

Still very experimental and bound to change. Example of its use can be found in Quarkus.