Skip to content

Conversation

@wfouche
Copy link
Contributor

@wfouche wfouche commented Jan 9, 2026

Initial support for #1979

$ jbang run camel:4.14.2@<username> version
[jbang] Resolving dependencies...
[jbang]    org.apache.camel:camel-jbang-core:4.14.2
[jbang]    org.apache.camel.kamelets:camel-kamelets:4.14.2
[jbang]    org.apache.camel:camel-bom:4.14.2@pom
[jbang] Dependencies resolved
JBang version: 0.135.1
Camel JBang version: 4.14.2

CamelJBang.java

//JAVA 17+
//REPOS central=https://repo1.maven.org/maven2,apache-snapshot=https://repository.apache.org/content/groups/snapshots/
//DEPS org.apache.camel:camel-bom:${jbang.app.version:4.16.0}@pom
//DEPS org.apache.camel:camel-jbang-core:${jbang.app.version:4.16.0}
//DEPS org.apache.camel.kamelets:camel-kamelets:${jbang.app.version:4.16.0}

package main;

import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;

/**
 * Main to run CamelJBang
 */
public class CamelJBang {

    public static void main(String... args) {
        CamelJBangMain.run(args);
    }

}

@wfouche wfouche marked this pull request as draft January 10, 2026 08:06
@wfouche wfouche marked this pull request as ready for review January 10, 2026 11:02
}

private ResourceRef resolveChecked(ResourceResolver resolver, String resource) {
public String extractJBangAppVersion(String _resource) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this method does not feel right.

it is not actually extracting the version - it is detecting and putting it into a global system property and then returns it self.

we shouldn't rely on global state for this - its very local for the exact resolution of versions for alias ref.

Copy link
Collaborator

Choose a reason for hiding this comment

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

even if we had to use global state this method should be possible to test in isolation which we can't if reliant on global system property state.

}
String scriptRef = scriptMixin.scriptOrFile;
ProjectBuilder pb = createProjectBuilder();
String scriptRef = pb.extractJBangAppVersion(scriptMixin.scriptOrFile);
Copy link
Collaborator

Choose a reason for hiding this comment

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

it shouldn't have to extract a version here always should it ? normally should only be needed if alias actually have a version to set, right?

}

private static void installScripts(String name, String scriptRef, List<String> runOpts, List<String> runArgs)
private static void installScripts(String name, String _scriptRef, List<String> runOpts, List<String> runArgs)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why need to put _ in the signature parameter?

binDir.toFile().mkdirs();
String version = System.getProperty("jbang.app.version");
String scriptRef = _scriptRef;
if (version != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this logic seems in reverse of what I would expect.

I would assume if and only if a version is specified in the alias will we pass down version info to be resolved. No need to do this otherwise.

@wfouche
Copy link
Contributor Author

wfouche commented Jan 10, 2026

This implementaton is largely a proof-of-concept. Looking at the code again, I think one should rather enhance the ResourceRef class to support resource versioning. The current implementation removes the version information from the resource ref up-front and then adds it back where needed during back-end processing in order not to break current functionality. But it does not fit really well into the JBang processing model.

@wfouche wfouche marked this pull request as draft January 10, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants