jbang icon indicating copy to clipboard operation
jbang copied to clipboard

jbang edit --sandbox does not respect //JAVA version tag

Open simschla opened this issue 5 months ago • 3 comments

Describe the bug My Java file intro has a //JAVA 21 version tag, when running jbang edit --sandbox MyFile.java the resulting gradle project does not specify/configure this version.

To Reproduce Steps to reproduce the behavior:

  1. Create a Java File MyFile.java to run in jbang having the java version tag //JAVA 21
  2. Launch jbang edit --sandbox MyFile.java
  3. In the resulting project, open build.gradle
  4. See that there is a configuration block for the jdk version missing.

Expected behavior I would expect the build.gradle file to contain a block to specify java language version:

java {
	toolchain {
		languageVersion = JavaLanguageVersion.of(21)
         }
}

JBang version

[jbang] [0:175] jbang version 0.126.0
Cache: /Users/simschla/.jbang/cache
Config: /Users/simschla/.jbang
Repository: /Users/simschla/.m2/repository
Java: /Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home [11.0.27]
OS: mac
Arch: aarch64
Shell: bash
0.126.0

Additional context It looks to me, that src/main/resources/export-build.qute.gradle would handle this correctly, but src/main/resources/build.qute.gradle does not.

simschla avatar May 19 '25 05:05 simschla

@maxandersen perhaps now that we have an official export gradle command we should use that for the edit feature? Wdyt?

quintesse avatar May 19 '25 09:05 quintesse

@quintesse maybe but export gradle aren't compatible with "sandbox" afaik....i.e. you need files symbolic linked rather than "exported" ?

maxandersen avatar May 19 '25 10:05 maxandersen

Ah yes, I forgot about that. Then the only other thing I could imagine is that the gradle build file generation would be made static and public so the edit could re-use it. Not sure if it's worth it, but having only a single piece of code that generates gradle build file is probably a good idea :-)

quintesse avatar May 19 '25 10:05 quintesse