-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
667 additions
and
78 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
...r-json/src/main/resources/codestarts/quarkus-jbang/code/jbang-resteasy-code/codestart.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: jbang-resteasy-code | ||
ref: resteasy | ||
type: code | ||
language: | ||
base: | ||
data: | ||
resource: | ||
class-name: ExampleResource | ||
path: "/resteasy/hello" | ||
response: "hello" | ||
dependencies: | ||
- io.quarkus:quarkus-resteasy | ||
|
27 changes: 27 additions & 0 deletions
27
...odestarts/quarkus-jbang/code/jbang-resteasy-code/java/{resource.class-name}.tpl.qute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//usr/bin/env jbang "$0" "$@" ; exit $? | ||
//REPOS xamdk=https://xam.dk/maven | ||
{#for dep in dependencies} | ||
//DEPS {dep.formatted-ga}:{quarkus.version} | ||
{/for} | ||
|
||
//JAVA_OPTIONS -Djava.util.logging.manager=org.jboss.logmanager.LogManager | ||
//Q:CONFIG quarkus.swagger-ui.always-include=true | ||
|
||
import io.quarkus.runtime.Quarkus; | ||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
|
||
@Path("{resource.path}") | ||
@ApplicationScoped | ||
public class {resource.class-name} { | ||
|
||
@GET | ||
public String sayHello() { | ||
return "{resource.response}"; | ||
} | ||
|
||
public static void main(String[] args) { | ||
Quarkus.run(args); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...m-descriptor-json/src/main/resources/codestarts/quarkus-jbang/language/java/codestart.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: java | ||
type: language | ||
fallback: true |
30 changes: 30 additions & 0 deletions
30
...r-json/src/main/resources/codestarts/quarkus-jbang/project/quarkus-jbang/base/..gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Eclipse | ||
.project | ||
.classpath | ||
.settings/ | ||
bin/ | ||
|
||
# IntelliJ | ||
.idea | ||
*.ipr | ||
*.iml | ||
*.iws | ||
|
||
# NetBeans | ||
nb-configuration.xml | ||
|
||
# Visual Studio Code | ||
.vscode | ||
.factorypath | ||
|
||
# OSX | ||
.DS_Store | ||
|
||
# Vim | ||
*.swp | ||
*.swo | ||
|
||
# patch | ||
*.orig | ||
*.rej | ||
|
1 change: 1 addition & 0 deletions
1
...esources/codestarts/quarkus-jbang/project/quarkus-jbang/base/README.tpl.qute.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# JBang quarkus project |
12 changes: 12 additions & 0 deletions
12
...ptor-json/src/main/resources/codestarts/quarkus-jbang/project/quarkus-jbang/codestart.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: quarkus-jbang | ||
type: project | ||
fallback: true | ||
output-strategy: | ||
"README.md": append | ||
"readme.md": forbidden | ||
"README.adoc": forbidden | ||
"readme.adoc": forbidden | ||
".gitignore": append | ||
"*": fail-on-duplicate | ||
|
||
|
158 changes: 158 additions & 0 deletions
158
...criptor-json/src/main/resources/codestarts/quarkus-jbang/tooling/jbang-wrapper/base/jbang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
#!/usr/bin/env bash | ||
|
||
# | ||
# To run this script remotely type this in your shell | ||
# (where <args>... are the arguments you want to pass to Jbang): | ||
# curl -Ls https://sh.jbang.dev | bash -s - <args>... | ||
# | ||
|
||
# The Java version to install when it's not installed on the system yet | ||
javaVersion=${JBANG_DEFAULT_JAVA_VERSION:-11} | ||
|
||
absolute_path() { | ||
# if the given path to the jbang launcher is absolute (i.e. it is either starting with / or a | ||
# 'letter:/' when using gitbash on windows) it is returned unchanged, otherwise we construct an absolute path | ||
[[ $1 = /* ]] || [[ $1 =~ ^[A-z]:/ ]] && echo "$1" || echo "$PWD/${1#./}" | ||
} | ||
|
||
resolve_symlink() { | ||
if [[ $OSTYPE != darwin* ]]; then minusFarg="-f"; fi | ||
sym_resolved=$(readlink ${minusFarg} $1) | ||
|
||
if [[ -n $sym_resolved ]]; then | ||
echo $sym_resolved | ||
else | ||
echo $1 | ||
fi | ||
} | ||
|
||
download() { | ||
if [ -x "$(command -v curl)" ]; then | ||
curl -sLf -H "Accept: application/gzip, application/octet-stream" -o "$2" $1 | ||
retval=$? | ||
elif [ -x "$(command -v wget)" ]; then | ||
wget -q --header="Accept: application/gzip, application/octet-stream" -O "$2" $1 | ||
retval=$? | ||
else | ||
echo "Error: curl or wget not found, please make sure one of them is installed" 1>&2 | ||
exit 1 | ||
fi | ||
} | ||
|
||
abs_jbang_path=/usr/local/Cellar/jbang/0.51.1/libexec/bin/jbang.jar | ||
|
||
case "$(uname -s)" in | ||
Linux*) | ||
os=linux;; | ||
Darwin*) | ||
os=mac;; | ||
CYGWIN*|MINGW*) | ||
os=windows;; | ||
*) echo "Unsupported Operating System: $(uname -s)" 1>&2; exit 1;; | ||
esac | ||
|
||
case "$(uname -m)" in | ||
i?86) | ||
arch=x32;; | ||
x86_64|amd64) | ||
arch=x64;; | ||
aarch64) | ||
arch=aarch64;; | ||
*) | ||
echo "Unsupported Architecture: $(uname -m)" 1>&2; exit 1;; | ||
esac | ||
|
||
## when mingw/git bash or cygwin fall out to just running the bat file. | ||
if [[ $os == windows ]]; then | ||
$(dirname $abs_jbang_path)/jbang.cmd $* | ||
exit $? | ||
fi | ||
|
||
if [[ -z "$JBANG_DIR" ]]; then JBDIR="$HOME/.jbang"; else JBDIR="$JBANG_DIR"; fi | ||
if [[ -z "$JBANG_CACHE_DIR" ]]; then TDIR="$JBDIR/cache"; else TDIR="$JBANG_CACHE_DIR"; fi | ||
|
||
## resolve application jar path from script location | ||
if [ -f "$(dirname $abs_jbang_path)/jbang.jar" ]; then | ||
jarPath=$(dirname $abs_jbang_path)/jbang.jar | ||
elif [ -f "$(dirname $abs_jbang_path)/.jbang/jbang.jar" ]; then | ||
jarPath=$(dirname $abs_jbang_path)/.jbang/jbang.jar | ||
else | ||
if [ ! -f "$JBDIR/bin/jbang.jar" ]; then | ||
echo "Downloading JBang..." 1>&2 | ||
mkdir -p "$TDIR/urls" | ||
jburl="https://github.com/jbangdev/jbang/releases/latest/download/jbang.tar" | ||
download $jburl "$TDIR/urls/jbang.tar" | ||
if [ $retval -ne 0 ]; then echo "Error downloading JBang" 1>&2; exit $retval; fi | ||
echo "Installing JBang..." 1>&2 | ||
rm -rf "$TDIR/urls/jbang" | ||
tar xf "$TDIR/urls/jbang.tar" -C "$TDIR/urls" | ||
if [ $retval -ne 0 ]; then echo "Error installing JBang" 1>&2; exit $retval; fi | ||
rm -rf "$JBDIR/bin" | ||
mv "$TDIR/urls/jbang/bin" "$JBDIR" | ||
fi | ||
eval "exec $JBDIR/bin/jbang $*" | ||
fi | ||
|
||
# Find/get a JDK | ||
unset JAVA_EXEC | ||
if [[ -n "$JAVA_HOME" ]]; then | ||
# Determine if a (working) JDK is available in JAVA_HOME | ||
if [ -x "$(command -v $JAVA_HOME/bin/javac)" ]; then | ||
JAVA_EXEC="$JAVA_HOME/bin/java"; | ||
else | ||
echo "JAVA_HOME is set but does not seem to point to a valid Java JDK" 1>&2 | ||
fi | ||
fi | ||
if [[ -z "$JAVA_EXEC" ]]; then | ||
# Determine if a (working) JDK is available on the PATH | ||
if [ -x "$(command -v javac)" ]; then | ||
JAVA_EXEC="java"; | ||
elif [ -x "$JBDIR/currentjdk/bin/javac" ]; then | ||
export JAVA_HOME="$JBDIR/currentjdk" | ||
JAVA_EXEC="$JBDIR/currentjdk/bin/java"; | ||
else | ||
export JAVA_HOME="$TDIR/jdks/$javaVersion" | ||
JAVA_EXEC="$JAVA_HOME/bin/java" | ||
# Check if we installed a JDK before | ||
if [ ! -d "$TDIR/jdks/$javaVersion" ]; then | ||
# If not, download and install it | ||
mkdir -p "$TDIR/jdks" | ||
echo "Downloading JDK $javaVersion. Be patient, this can take several minutes..." 1>&2 | ||
jdkurl="https://api.adoptopenjdk.net/v3/binary/latest/$javaVersion/ga/$os/$arch/jdk/hotspot/normal/adoptopenjdk" | ||
download $jdkurl "$TDIR/bootstrap-jdk.tgz" | ||
if [ $retval -ne 0 ]; then echo "Error downloading JDK" 1>&2; exit $retval; fi | ||
echo "Installing JDK $javaVersion..." 1>&2 | ||
rm -rf "$TDIR/jdks/$javaVersion.tmp/" | ||
mkdir -p "$TDIR/jdks/$javaVersion.tmp" | ||
tar xf "$TDIR/bootstrap-jdk.tgz" -C "$TDIR/jdks/$javaVersion.tmp" --strip-components=1 | ||
retval=$? | ||
if [[ $os == mac && $retval -eq 0 ]]; then | ||
mv "$TDIR/jdks/$javaVersion.tmp/Contents/Home/"* "$TDIR/jdks/$javaVersion.tmp/" | ||
retval=$? | ||
fi | ||
if [ $retval -ne 0 ]; then | ||
# Check if the JDK was installed properly | ||
javac -version > /dev/null 2>&1 | ||
retval=$? | ||
fi | ||
if [ $retval -ne 0 ]; then echo "Error installing JDK" 1>&2; exit $retval; fi | ||
# Activate the downloaded JDK giving it its proper name | ||
mv "$TDIR/jdks/$javaVersion.tmp" "$TDIR/jdks/$javaVersion" | ||
# Set the current JDK | ||
${JAVA_EXEC} -classpath ${jarPath} dev.jbang.Main jdk default $javaVersion | ||
fi | ||
fi | ||
fi | ||
|
||
## https://stackoverflow.com/questions/1668649/how-to-keep-quotes-in-bash-arguments | ||
## attempt to ensure each argument keeps its original quoting | ||
|
||
## run it using command substitution to have just the user process once jbang is done | ||
output=$(CLICOLOR_FORCE=1 ${JAVA_EXEC} ${JBANG_JAVA_OPTIONS} -classpath ${jarPath} dev.jbang.Main "$@") | ||
err=$? | ||
if [ $err -eq 255 ]; then | ||
eval "exec $output" | ||
else | ||
echo "$output" | ||
exit $err | ||
fi |
109 changes: 109 additions & 0 deletions
109
...tor-json/src/main/resources/codestarts/quarkus-jbang/tooling/jbang-wrapper/base/jbang.cmd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
@echo off | ||
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION | ||
|
||
|
||
rem The Java version to install when it's not installed on the system yet | ||
if "%JBANG_DEFAULT_JAVA_VERSION%"=="" (set javaVersion=11) else (set javaVersion=%JBANG_DEFAULT_JAVA_VERSION%) | ||
|
||
set os=windows | ||
set arch=x64 | ||
|
||
set jburl="https://github.com/jbangdev/jbang/releases/latest/download/jbang.zip" | ||
set jdkurl="https://api.adoptopenjdk.net/v3/binary/latest/%javaVersion%/ga/%os%/%arch%/jdk/hotspot/normal/adoptopenjdk" | ||
|
||
if "%JBANG_DIR%"=="" (set JBDIR=%userprofile%\.jbang) else (set JBDIR=%JBANG_DIR%) | ||
if "%JBANG_CACHE_DIR%"=="" (set TDIR=%JBDIR%\cache) else (set TDIR=%JBANG_CACHE_DIR%) | ||
|
||
rem resolve application jar path from script location and convert to windows path when using cygwin | ||
if exist "%~dp0jbang.jar" ( | ||
set jarPath=%~dp0jbang.jar | ||
) else if exist "%~dp0.jbang\jbang.jar" ( | ||
set jarPath=%~dp0.jbang\jbang.jar | ||
) else ( | ||
if not exist "%JBDIR%\bin\jbang.jar" ( | ||
echo Downloading JBang... 1>&2 | ||
if not exist "%TDIR%\urls" ( mkdir "%TDIR%\urls" ) | ||
powershell -NoProfile -ExecutionPolicy Bypass -NonInteractive -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest %jburl% -OutFile %TDIR%\urls\jbang.zip" | ||
if !ERRORLEVEL! NEQ 0 ( echo Error downloading JBang 1>&2 & exit /b %ERRORLEVEL% ) | ||
echo Installing JBang... 1>&2 | ||
if exist "%TDIR%\urls\jbang" ( rd /s /q "%TDIR%\urls\jbang" > nul 2>&1 ) | ||
powershell -NoProfile -ExecutionPolicy Bypass -NonInteractive -Command "$ProgressPreference = 'SilentlyContinue'; Expand-Archive -Path %TDIR%\urls\jbang.zip -DestinationPath %TDIR%\urls" | ||
if !ERRORLEVEL! NEQ 0 ( echo Error installing JBang 1>&2 & exit /b %ERRORLEVEL% ) | ||
if exist "%JBDIR%\bin" ( rd /s /q "%JBDIR%\bin" > nul 2>&1 ) | ||
move "%TDIR%\urls\jbang\bin" "%JBDIR%" > nul 2>&1 | ||
) | ||
call "%JBDIR%\bin\jbang.cmd" %* | ||
exit /b %ERRORLEVEL% | ||
) | ||
|
||
rem Find/get a JDK | ||
set JAVA_EXEC= | ||
if not "%JAVA_HOME%"=="" ( | ||
rem Determine if a (working) JDK is available in JAVA_HOME | ||
if exist "%JAVA_HOME%\bin\javac.exe" ( | ||
set JAVA_EXEC="%JAVA_HOME%\bin\java.exe" | ||
) else ( | ||
echo JAVA_HOME is set but does not seem to point to a valid Java JDK 1>&2 | ||
) | ||
) | ||
if "!JAVA_EXEC!"=="" ( | ||
rem Determine if a (working) JDK is available on the PATH | ||
where javac > nul 2>&1 | ||
if !errorlevel! equ 0 ( | ||
set JAVA_EXEC=java.exe | ||
) else if exist "%JBDIR%\currentjdk\bin\javac" ( | ||
set JAVA_HOME=%JBDIR%\currentjdk | ||
set JAVA_EXEC=%JBDIR%\currentjdk\bin\java | ||
) else ( | ||
set JAVA_HOME=%TDIR%\jdks\%javaVersion% | ||
set JAVA_EXEC=!JAVA_HOME!\bin\java.exe | ||
rem Check if we installed a JDK before | ||
if not exist "%TDIR%\jdks\%javaVersion%" ( | ||
rem If not, download and install it | ||
if not exist "%TDIR%\jdks" ( mkdir "%TDIR%\jdks" ) | ||
echo Downloading JDK %javaVersion%. Be patient, this can take several minutes... 1>&2 | ||
powershell -NoProfile -ExecutionPolicy Bypass -NonInteractive -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest %jdkurl% -OutFile %TDIR%\bootstrap-jdk.zip" | ||
if !ERRORLEVEL! NEQ 0 ( echo Error downloading JDK 1>&2 & exit /b %ERRORLEVEL% ) | ||
echo Installing JDK %javaVersion%... 1>&2 | ||
if exist "%TDIR%\jdks\%javaVersion%.tmp" ( rd /s /q "%TDIR%\jdks\%javaVersion%.tmp" > nul 2>&1 ) | ||
powershell -NoProfile -ExecutionPolicy Bypass -NonInteractive -Command "$ProgressPreference = 'SilentlyContinue'; Expand-Archive -Path %TDIR%\bootstrap-jdk.zip -DestinationPath %TDIR%\jdks\%javaVersion%.tmp" | ||
if !ERRORLEVEL! NEQ 0 ( echo Error installing JDK 1>&2 & exit /b %ERRORLEVEL% ) | ||
for /d %%d in (%TDIR%\jdks\%javaVersion%.tmp\*) do ( | ||
powershell -NoProfile -ExecutionPolicy Bypass -NonInteractive -Command "Move-Item %%d\* !TDIR!\jdks\%javaVersion%.tmp" | ||
if !ERRORLEVEL! NEQ 0 ( echo Error installing JDK 1>&2 & exit /b %ERRORLEVEL% ) | ||
) | ||
rem Check if the JDK was installed properly | ||
%TDIR%\jdks\%javaVersion%.tmp\bin\javac -version > nul 2>&1 | ||
if !ERRORLEVEL! NEQ 0 ( echo "Error installing JDK" 1>&2; exit /b %ERRORLEVEL% ) | ||
rem Activate the downloaded JDK giving it its proper name | ||
ren "%TDIR%\jdks\%javaVersion%.tmp" "%javaVersion%" | ||
) | ||
# Set the current JDK | ||
!JAVA_EXEC! -classpath ${jarPath} dev.jbang.Main jdk default "%javaVersion%" | ||
) | ||
) | ||
|
||
if not exist "%TDIR%" ( mkdir "%TDIR%" ) | ||
set tmpfile=%TDIR%\%RANDOM%.jbang.tmp | ||
rem execute jbang and pipe to temporary random file | ||
set "CMD=!JAVA_EXEC!" | ||
SETLOCAL DISABLEDELAYEDEXPANSION | ||
%CMD% > "%tmpfile%" %JBANG_JAVA_OPTIONS% -classpath "%jarPath%" dev.jbang.Main %* | ||
set ERROR=%ERRORLEVEL% | ||
rem catch errorlevel straight after; rem or FOR /F swallow would have swallowed the errorlevel | ||
|
||
if %ERROR% EQU 255 ( | ||
rem read generated java command by jang, delete temporary file and execute. | ||
for %%A in ("%tmpfile%") do for /f "usebackq delims=" %%B in (%%A) do ( | ||
set "OUTPUT=%%B" | ||
goto :break | ||
) | ||
:break | ||
del "%tmpfile%" | ||
%OUTPUT% | ||
exit /b %ERRORLEVEL% | ||
) else ( | ||
type "%tmpfile%" | ||
del "%tmpfile%" | ||
exit /b %ERROR% | ||
) |
5 changes: 5 additions & 0 deletions
5
...ptor-json/src/main/resources/codestarts/quarkus-jbang/tooling/jbang-wrapper/codestart.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name: jbang-wrapper | ||
type: tooling | ||
output-strategy: | ||
"jbang": "executable" | ||
"jbang.cmd": "executable" |
3 changes: 0 additions & 3 deletions
3
...json/src/main/resources/codestarts/quarkus/core/buildtool/gradle-kotlin-dsl/codestart.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
...descriptor-json/src/main/resources/codestarts/quarkus/core/buildtool/gradle/codestart.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
...-descriptor-json/src/main/resources/codestarts/quarkus/core/buildtool/maven/codestart.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.