Skip to content

Commit

Permalink
modified windows scripts for ninja.jar added ninja.bat
Browse files Browse the repository at this point in the history
  • Loading branch information
KristianSuchanovsky authored and semancik committed Mar 2, 2018
1 parent 92a79a6 commit e75ff78
Show file tree
Hide file tree
Showing 4 changed files with 323 additions and 273 deletions.
112 changes: 16 additions & 96 deletions dist/src/main/bin/export.bat
Expand Up @@ -4,104 +4,24 @@ setlocal

set "BIN_DIR=%~dp0"

:parse
if "%~1"=="" goto endparse
if "%~1"=="-c" (
set "OPTIONS=%OPTIONS% %~1 %~2"
)
if "%~1"=="-h" (
set "OPTIONS=%OPTIONS% %~1"
)
if "%~1"=="-m" (
echo midpoint.home set by default
)
if "%~1"=="-p" (
set "OPTIONS=%OPTIONS% %~1 %~2"
)
if "%~1"=="-P" (
set "OPTIONS=%OPTIONS% %~1 %~2"
)
if "%~1"=="-s" (
set "OPTIONS=%OPTIONS% %~1"
)
if "%~1"=="-U" (
set "OPTIONS=%OPTIONS% %~1 %~2"
)
if "%~1"=="-u" (
set "OPTIONS=%OPTIONS% %~1 %~2"
)
if "%~1"=="-v" (
set "OPTIONS=%OPTIONS% %~1"
)
if "%~1"=="-V" (
set "OPTIONS=%OPTIONS% %~1"
)
if "%~1"=="-f" (
set "EXP_OPTIONS=%EXP_OPTIONS% %~1 %~2"
)
if "%~1"=="-o" (
set "EXP_OPTIONS=%EXP_OPTIONS% %~1 %~2"
)
if "%~1"=="-O" (
echo Output file already set by default"
)
if "%~1"=="-r" (
set "EXP_OPTIONS=%EXP_OPTIONS% %~1"
)
if "%~1"=="-t" (
set "EXP_OPTIONS=%EXP_OPTIONS% %~1 %~2"
)
if "%~1"=="-z" (
set "EXP_OPTIONS=%EXP_OPTIONS% %~1"
)
shift
goto parse
:endparse

echo "BIN DIR %BIN_DIR%"
rem if script for export is in bin directory
if exist "%BIN_DIR%\export.bat" goto okBoot
echo %BIN_DIR%
echo The export.bat file is not in \bin
goto end
:okBoot

rem set midpoint.home
if not "%MIDPOINT_HOME%" == "" goto gotHome
cd "%BIN_DIR%.."
if exist "%BIN_DIR%..\var" goto setHome
echo %BIN_DIR%
echo ERROR: midpoint.home directory desn't exist
goto end
:setHome

set "MIDPOINT_HOME=%cd%\var"
echo %MIDPOINT_HOME%
echo %BIN_DIR%
:gotHome
set "EXECUTABLE=%BIN_DIR%\ninja.bat"

rem NINJA_JAR if not defined
if exist "%cd%\lib\ninja.jar" goto gotJar
echo The ninja.jar is not in \lib directory
echo Can not start ninja
rem Check that target executable exists
if exist "%EXECUTABLE%" goto okExec
echo Cannot find "%EXECUTABLE%"
echo This file is needed to run this program
goto end
:gotJar
:okExec

if "%MIDPOINT_HOME%" == "%MIDPOINT_HOME:;=%" goto homeNoSemicolon
echo Using MIDPOINT_HOME: "%MIDPOINT_HOME%"
echo Unable to start as MIDPOINT_HOME contains a semicolon (;) character
goto end
:homeNoSemicolon

For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a-%%b)
echo %mydate%_%mytime%

rem ----- Execute The Requested Command ---------------------------------------

echo Using MIDPOINT_HOME: "%MIDPOINT_HOME%"

start /b java -jar "%cd%\lib\ninja.jar" %OPTIONS% -m "%MIDPOINT_HOME%" export %EXP_OPTIONS% -O "export.%mydate%_%mytime%.xml"
rem Get remaining unshifted command line arguments and save them in the
set CMD_LINE_ARGS=
:setArgs
if ""%1""=="""" goto doneSetArgs
set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
shift
goto setArgs
:doneSetArgs

call "%EXECUTABLE%" export %CMD_LINE_ARGS%

:end
:end
112 changes: 15 additions & 97 deletions dist/src/main/bin/import.bat
Expand Up @@ -4,106 +4,24 @@ setlocal

set "BIN_DIR=%~dp0"

:parse
if "%~1"=="" goto endparse
if "%~1"=="-c" (
set "OPTIONS=%OPTIONS% %~1 %~2"
)
if "%~1"=="-h" (
set "OPTIONS=%OPTIONS% %~1"
)
if "%~1"=="-m" (
echo midpoint.home set by default
)
if "%~1"=="-p" (
set "OPTIONS=%OPTIONS% %~1 %~2"
)
if "%~1"=="-P" (
set "OPTIONS=%OPTIONS% %~1 %~2"
)
if "%~1"=="-s" (
set "OPTIONS=%OPTIONS% %~1"
)
if "%~1"=="-U" (
set "OPTIONS=%OPTIONS% %~1 %~2"
)
if "%~1"=="-u" (
set "OPTIONS=%OPTIONS% %~1 %~2"
)
if "%~1"=="-v" (
set "OPTIONS=%OPTIONS% %~1"
)
if "%~1"=="-V" (
set "OPTIONS=%OPTIONS% %~1"
)
if "%~1"=="-e" (
set "IMP_OPTIONS=%IMP_OPTIONS% %~1"
)
if "%~1"=="-f" (
set "IMP_OPTIONS=%IMP_OPTIONS% %~1 %~2"
)
if "%~1"=="-i" (
set "IMP_OPTIONS=%IMP_OPTIONS% %~1 %~2"
)
if "%~1"=="-o" (
set "IMP_OPTIONS=%IMP_OPTIONS% %~1 %~2"
)
if "%~1"=="-O" (
echo Overwrite already set by default"
)
if "%~1"=="-r" (
set "IMP_OPTIONS=%IMP_OPTIONS% %~1"
)
if "%~1"=="-t" (
set "IMP_OPTIONS=%IMP_OPTIONS% %~1 %~2"
)
if "%~1"=="-z" (
set "IMP_OPTIONS=%IMP_OPTIONS% %~1"
)
shift
goto parse
:endparse

echo "BIN DIR %BIN_DIR%"
rem if script for export is in bin directory
if exist "%BIN_DIR%\import.bat" goto okBoot
echo %BIN_DIR%
echo The import.bat file is not in \bin
goto end
:okBoot

rem set midpoint.home
if not "%MIDPOINT_HOME%" == "" goto gotHome
cd "%BIN_DIR%.."
if exist "%BIN_DIR%..\var" goto setHome
echo %BIN_DIR%
echo ERROR: midpoint.home directory desn't exist
goto end
:setHome

set "MIDPOINT_HOME=%cd%\var"
echo %MIDPOINT_HOME%
echo %BIN_DIR%
:gotHome
set "EXECUTABLE=%BIN_DIR%\ninja.bat"

rem NINJA_JAR if not defined
if exist "%cd%\lib\ninja.jar" goto gotJar
echo The ninja.jar is not in \lib directory
echo Can not start ninja
rem Check that target executable exists
if exist "%EXECUTABLE%" goto okExec
echo Cannot find "%EXECUTABLE%"
echo This file is needed to run this program
goto end
:okExec

:gotJar
if "%MIDPOINT_HOME%" == "%MIDPOINT_HOME:;=%" goto homeNoSemicolon
echo Using MIDPOINT_HOME: "%MIDPOINT_HOME%"
echo Unable to start as MIDPOINT_HOME contains a semicolon (;) character
goto end

:homeNoSemicolon

rem ----- Execute The Requested Command ---------------------------------------

echo Using MIDPOINT_HOME: "%MIDPOINT_HOME%"
rem Get remaining unshifted command line arguments and save them in the
set CMD_LINE_ARGS=
:setArgs
if ""%1""=="""" goto doneSetArgs
set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
shift
goto setArgs
:doneSetArgs

start /b java -jar "%cd%\lib\ninja.jar" %OPTIONS% -m "%MIDPOINT_HOME%" import %IMP_OPTIONS% -O
call "%EXECUTABLE%" import %CMD_LINE_ARGS%

:end
95 changes: 15 additions & 80 deletions dist/src/main/bin/keys.bat
Expand Up @@ -4,89 +4,24 @@ setlocal

set "BIN_DIR=%~dp0"

:parse
if "%~1"=="" goto endparse
if "%~1"=="-c" (
set "OPTIONS=%OPTIONS% %~1 %~2"
)
if "%~1"=="-h" (
set "OPTIONS=%OPTIONS% %~1"
)
if "%~1"=="-m" (
echo midpoint.home set by default
)
if "%~1"=="-p" (
set "OPTIONS=%OPTIONS% %~1 %~2"
)
if "%~1"=="-P" (
set "OPTIONS=%OPTIONS% %~1 %~2"
)
if "%~1"=="-s" (
set "OPTIONS=%OPTIONS% %~1"
)
if "%~1"=="-U" (
set "OPTIONS=%OPTIONS% %~1 %~2"
)
if "%~1"=="-u" (
set "OPTIONS=%OPTIONS% %~1 %~2"
)
if "%~1"=="-v" (
set "OPTIONS=%OPTIONS% %~1"
)
if "%~1"=="-V" (
set "OPTIONS=%OPTIONS% %~1"
)
if "%~1"=="-k" (
set "KEY_OPTIONS=%KEY_OPTIONS% %~1 %~2"
)
if "%~1"=="-K" (
set "KEY_OPTIONS=%KEY_OPTIONS% %~1"
)
shift
goto parse
:endparse

echo "BIN DIR %BIN_DIR%"
rem if script for export is in bin directory
if exist "%BIN_DIR%\keys.bat" goto okBoot
echo %BIN_DIR%
echo The keys.bat file is not in \bin
goto end
:okBoot

rem set midpoint.home
if not "%MIDPOINT_HOME%" == "" goto gotHome
cd "%BIN_DIR%.."
if exist "%BIN_DIR%..\var" goto setHome
echo %BIN_DIR%
echo ERROR: midpoint.home directory desn't exist
goto end
:setHome

set "MIDPOINT_HOME=%cd%\var"
echo %MIDPOINT_HOME%
echo %BIN_DIR%
:gotHome
set "EXECUTABLE=%BIN_DIR%\ninja.bat"

rem NINJA_JAR if not defined
if exist "%cd%\lib\ninja.jar" goto gotJar
echo The ninja.jar is not in \lib directory
echo Can not start ninja
rem Check that target executable exists
if exist "%EXECUTABLE%" goto okExec
echo Cannot find "%EXECUTABLE%"
echo This file is needed to run this program
goto end
:okExec

:gotJar
if "%MIDPOINT_HOME%" == "%MIDPOINT_HOME:;=%" goto homeNoSemicolon
echo Using MIDPOINT_HOME: "%MIDPOINT_HOME%"
echo Unable to start as MIDPOINT_HOME contains a semicolon (;) character
goto end

:homeNoSemicolon

rem ----- Execute The Requested Command ---------------------------------------

echo Using MIDPOINT_HOME: "%MIDPOINT_HOME%"

start /b java -jar "%cd%\lib\ninja.jar" %OPTIONS% -m "%MIDPOINT_HOME%" keys %KEY_OPTIONS%
rem Get remaining unshifted command line arguments and save them in the
set CMD_LINE_ARGS=
:setArgs
if ""%1""=="""" goto doneSetArgs
set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
shift
goto setArgs
:doneSetArgs

call "%EXECUTABLE%" keys %CMD_LINE_ARGS%

:end

0 comments on commit e75ff78

Please sign in to comment.