Add jbang: single-file Java with JBang 0.132.1 on JDK 25 (deps, compact source files, Spring Boot, templates, native)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b6ZEVHGaYy15HAxRzy
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
7c677a39d2
commit
ddc3ec9d90
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
# Runs JBang. Uses a real `jbang` launcher on PATH if there is one; otherwise emulates the
|
||||
# launcher around the jbang-cli fat jar from Maven Central.
|
||||
#
|
||||
# Why the emulation is needed: the jar does not run your script itself. It prints the final
|
||||
# `java ...` command line on stdout and exits with status 255, and the `jbang` shell launcher
|
||||
# evals that line. This script does the same.
|
||||
#
|
||||
# Environment noise ("Picked up JAVA_TOOL_OPTIONS ...") is stripped from stderr.
|
||||
JBANG_JAR="${JBANG_JAR:-/tmp/jb/jbang-cli-0.132.1-all.jar}"
|
||||
|
||||
if command -v jbang >/dev/null 2>&1; then
|
||||
exec jbang "$@"
|
||||
fi
|
||||
|
||||
out=$(java -jar "$JBANG_JAR" "$@" 2> >(grep -v '^Picked up' >&2))
|
||||
rc=$?
|
||||
if [ "$rc" -eq 255 ]; then
|
||||
eval "$out" 2> >(grep -v '^Picked up' >&2)
|
||||
exit $?
|
||||
fi
|
||||
[ -n "$out" ] && printf '%s\n' "$out"
|
||||
exit "$rc"
|
||||
Reference in New Issue
Block a user