| 1 | @echo off |
|---|
| 2 | |
|---|
| 3 | rem |
|---|
| 4 | rem Kauri Runtime startup script for use during Kauri development |
|---|
| 5 | rem meaning: there is no KAURI_HOME, Kauri artifacts are in dev's local Maven repo |
|---|
| 6 | rem |
|---|
| 7 | |
|---|
| 8 | rem You can use the following environment variables to customize the startup |
|---|
| 9 | rem |
|---|
| 10 | rem KAURI_CLI_CLASSPATH |
|---|
| 11 | rem additional entries to be added to the classpath |
|---|
| 12 | rem |
|---|
| 13 | rem KAURI_JAVA_ARGS |
|---|
| 14 | rem additional options to be passed to the java executable |
|---|
| 15 | rem |
|---|
| 16 | rem KAURI_DEBUG_ARGS |
|---|
| 17 | rem can be used to define alternative Java debug arguments |
|---|
| 18 | rem |
|---|
| 19 | rem KAURI_DEBUG_SUSPEND_ARGS |
|---|
| 20 | rem can be used to define alternative Java debug arguments for suspended mode |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | rem |
|---|
| 24 | rem Disclaimer: this script is based on stuff from Apache Cocoon's 'cocoon.bat' script |
|---|
| 25 | rem |
|---|
| 26 | |
|---|
| 27 | :: ----- Verify and Set Required Environment Variables ------------------------- |
|---|
| 28 | |
|---|
| 29 | if not "%JAVA_HOME%"=="" goto gotJavaHome |
|---|
| 30 | echo JAVA_HOME not set! |
|---|
| 31 | goto end |
|---|
| 32 | :gotJavaHome |
|---|
| 33 | |
|---|
| 34 | :: ----- Find out home dir of this script -------------------------------------- |
|---|
| 35 | |
|---|
| 36 | if not "%KAURI_SRC_HOME%"=="" goto gotKauriSrcHome |
|---|
| 37 | rem %~dp0 is expanded pathname of the current script under NT |
|---|
| 38 | set KAURI_SRC_HOME=%~dp0 |
|---|
| 39 | :gotKauriSrcHome |
|---|
| 40 | |
|---|
| 41 | :: ----- Check System Properties ----------------------------------------------- |
|---|
| 42 | |
|---|
| 43 | set LAUNCHER_JAR=%KAURI_SRC_HOME%\core\kauri-runtime-launcher\target\kauri-runtime-launcher.jar |
|---|
| 44 | |
|---|
| 45 | IF EXIST %LAUNCHER_JAR% goto launcherJarExists |
|---|
| 46 | echo Launcher jar not found at %LAUNCHER_JAR% |
|---|
| 47 | echo Please build Kauri first using 'mvn install' |
|---|
| 48 | goto end |
|---|
| 49 | |
|---|
| 50 | :launcherJarExists |
|---|
| 51 | |
|---|
| 52 | set CLASSPATH=%LAUNCHER_JAR% |
|---|
| 53 | |
|---|
| 54 | rem Only add KAURI_CLI_CLASSPATH when it is not empty, to avoid adding the working dir to |
|---|
| 55 | rem the classpath by accident. |
|---|
| 56 | if "%KAURI_CLI_CLASSPATH%"=="" goto noExtraClassPath |
|---|
| 57 | set CLASSPATH=%CLASSPATH%;%KAURI_CLI_CLASSPATH% |
|---|
| 58 | :noExtraClassPath |
|---|
| 59 | |
|---|
| 60 | if not "%KAURI_DEBUG_ARGS%"=="" goto gotKauriDebugArgs |
|---|
| 61 | set KAURI_DEBUG_ARGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 |
|---|
| 62 | :gotKauriDebugArgs |
|---|
| 63 | |
|---|
| 64 | if not "%KAURI_DEBUG_SUSPEND_ARGS%"=="" goto gotKauriDebugSuspendArgs |
|---|
| 65 | set KAURI_DEBUG_SUSPEND_ARGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005 |
|---|
| 66 | :gotKauriDebugSuspendArgs |
|---|
| 67 | |
|---|
| 68 | :: ----- Build params to forward to Kauri -------------------------------------- |
|---|
| 69 | set action=%1 |
|---|
| 70 | |
|---|
| 71 | set param= |
|---|
| 72 | shift |
|---|
| 73 | :cliLoop |
|---|
| 74 | if "%1"=="" goto cliLoopEnd |
|---|
| 75 | if not "%1"=="" set param=%param% %1 |
|---|
| 76 | shift |
|---|
| 77 | goto cliLoop |
|---|
| 78 | |
|---|
| 79 | :cliLoopEnd |
|---|
| 80 | |
|---|
| 81 | :: ----- Check action ---------------------------------------------------------- |
|---|
| 82 | |
|---|
| 83 | if ""%action%"" == """" goto doRun |
|---|
| 84 | if ""%action%"" == ""run"" goto doRun |
|---|
| 85 | if ""%action%"" == ""debug"" goto doDebug |
|---|
| 86 | if ""%action%"" == ""debug-suspend"" goto doDebugSuspend |
|---|
| 87 | |
|---|
| 88 | echo Usage: kauri (action) |
|---|
| 89 | echo actions: |
|---|
| 90 | echo run Run the Kauri Runtime (default) |
|---|
| 91 | echo debug Run the Kauri Runtime, listed to debugger on port 5005 |
|---|
| 92 | echo debug-suspend Run the Kauri Runtime, suspend for debugger on port 5005 |
|---|
| 93 | echo: |
|---|
| 94 | echo To see help options for Kauri, use kauri run -h |
|---|
| 95 | echo To pass options to Kauri, use kauri run {options} |
|---|
| 96 | goto end |
|---|
| 97 | |
|---|
| 98 | :doRun |
|---|
| 99 | |
|---|
| 100 | "%JAVA_HOME%/bin/java" %KAURI_JAVA_ARGS% org.kauriproject.launcher.RuntimeCliLauncher %param% |
|---|
| 101 | goto end |
|---|
| 102 | |
|---|
| 103 | :doDebug |
|---|
| 104 | |
|---|
| 105 | "%JAVA_HOME%/bin/java" %KAURI_JAVA_ARGS% %KAURI_DEBUG_ARGS% org.kauriproject.launcher.RuntimeCliLauncher %param% |
|---|
| 106 | goto end |
|---|
| 107 | |
|---|
| 108 | :doDebugSuspend |
|---|
| 109 | echo: |
|---|
| 110 | echo Don't forget: you'll need to connect with a debugger for Kauri to start |
|---|
| 111 | echo: |
|---|
| 112 | "%JAVA_HOME%/bin/java" %KAURI_JAVA_ARGS% %KAURI_DEBUG_SUSPEND_ARGS% org.kauriproject.launcher.RuntimeCliLauncher %param% |
|---|
| 113 | goto end |
|---|
| 114 | |
|---|
| 115 | :end |
|---|
| 116 | if "%_EXIT_ERRORLEVEL%"=="true" exit %ERRORLEVEL% |
|---|