feat: add "jbang.source" and "jbang.dir" - #2643
Conversation
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thanks for working on this — the motivation is spot on, and the prior-art table in the issue makes a compelling case. Happy to see this landing. That said, looking at the implementation there are a few gaps versus what the issue proposes and what I think we need for consistency. Before iterating on the code I would like your input on the direction. Gaps / open questions
System property vs env varThe issue proposes both
If we set the env var in Naming
Would love your thoughts on these before the next iteration. 🙏 |
|
i see in the issue you suggest we only test this for local source ....but that means the behaviour now depends on how this is called? how about aliases? what will they use as source location? |
|
Thanks @max I looked your points and with :spark I have tried to move the discussion forward. From your findings:
In addition: implementation of Real gaps, agreedjshell. You're right, native. Also missed — but the gap is wider than this feature. Two I think are false positives
Doc anchor. Antora sets AliasesThese already work, and I should have said so. "The behaviour depends on how it's called"Yes — and I'd argue that is correct rather than a defect, because it is what every runtime we Naming — counter-proposalI take the point that "source" over-promises if the value can be a URL or a GAV. But So rather than one overloaded name, how about splitting the two questions?
On remote sources and the env varTwo constraints I ran into, which is why the PR is scoped the way it is. Setting the URI for remote sources contradicts two existing assertions: For the env var: the obstacle is bigger than The real problem is that JBang prints the command and the launcher executes it, and each
So it is closer to a launcher-protocol change than a One nuance on the convention argument: Proposed plan
Tell me which of those you want in this PR and I will reshape it. Also happy to be wrong on |
|
can you get your bot to summarize that text ? :) imo properties just isn't the way as native can't reliably get it same as jshell. For aliases - I don't grok why you are ok use the absolute file for aliases, but not for URLs? Fundementally though the big problem here is that this mechanism of getting which folder something is running from is NOT reliably the same as the folder of where the source was listed. It just isn't. for a source file, sure - you will want local dir of the source file. Maybe we should have two env vars set: JBANG_RUN_SOURCE which is the actual thing being requests, alias, jar, file, url etc |
Not even that is 100% true in all cases. Remember that sometimes we change the name of the file and we can even edit the code. In those cases the source file gets copied to the cache folder and it's compiled from that location. Now, I guess you'd normally would want the original path, but it won't be the actual source file being compiled/executed. |
Yes sorry about that... I made him even expand some places that I considered as not clear enough... Not easy to find the right tradeoff here… |
|
Maybe trying to contribute, assisted from ✨ isn't such a great idea... Still I hope it is OK for you to try to continue Point by point an answer on the different points discussed here. @quintesse is right, and it is a bug in this PRVerified against a build of this branch:
Which is your point, and I think it is the decisionThere are three things here, not two:
My hesitation about C standing in for B: it is defined more often but useful less often. #2642 is One thing in your rule I do not follow: a URL is empty "because it is downloaded to disk", but a GAV AliasesIt was never an alias-vs-URL rule. Env vars — agreed, and here is what it costsWorth knowing before we commit to it, because it is not a JBang prints the command and the launcher executes it, and each launcher has its own idiom:
So it is a launcher change more than a generator one. Do you want it inside this PR, or as a What I would do next
Separately, related to this topic and kind of a pre-requisite for the |
Fixes #2642
NOTE for the reviewer: I changed one existing test:
testProperties()used to split the generated command line onexample.javaand expect exactly 2 parts;-Djbang.sourcelegitimately puts the script path on the command line a second time, so the split now usesfakemain, the main class — the actual boundary between JVM options and program arguments, which appears exactly once.