@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem      http://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem  cantara-upgrade startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%..

@rem Add default JVM options here. You can also use JAVA_OPTS and CANTARA_UPGRADE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\lib\cantara-upgrade-5.1.9-SNAPSHOT.jar;%APP_HOME%\lib\cantara-components-5.1.9-SNAPSHOT.jar;%APP_HOME%\lib\mysql-connector-java-8.0.17.jar;%APP_HOME%\lib\mssql-jdbc-7.4.1.jre8.jar;%APP_HOME%\lib\ojdbc8-12.2.0.1.jar;%APP_HOME%\lib\hibernate-core-5.4.4.Final.jar;%APP_HOME%\lib\cantara-base-5.1.9-SNAPSHOT.jar;%APP_HOME%\lib\async-datastore-client-3.0.2.jar;%APP_HOME%\lib\datastore-v1-protos-1.0.1.jar;%APP_HOME%\lib\google-http-client-protobuf-1.22.0.jar;%APP_HOME%\lib\protobuf-java-3.6.1.jar;%APP_HOME%\lib\hibernate-commons-annotations-5.1.0.Final.jar;%APP_HOME%\lib\jboss-logging-3.3.2.Final.jar;%APP_HOME%\lib\javax.persistence-api-2.2.jar;%APP_HOME%\lib\javassist-3.24.0-GA.jar;%APP_HOME%\lib\byte-buddy-1.9.11.jar;%APP_HOME%\lib\antlr-2.7.7.jar;%APP_HOME%\lib\jboss-transaction-api_1.2_spec-1.1.1.Final.jar;%APP_HOME%\lib\jandex-2.0.5.Final.jar;%APP_HOME%\lib\classmate-1.3.4.jar;%APP_HOME%\lib\jaxb-runtime-2.3.1.jar;%APP_HOME%\lib\jaxb-api-2.3.1.jar;%APP_HOME%\lib\javax.activation-api-1.2.0.jar;%APP_HOME%\lib\dom4j-2.1.1.jar;%APP_HOME%\lib\httpmime-4.5.6.jar;%APP_HOME%\lib\google-api-client-1.23.0.jar;%APP_HOME%\lib\google-oauth-client-1.23.0.jar;%APP_HOME%\lib\google-http-client-jackson2-1.23.0.jar;%APP_HOME%\lib\google-http-client-1.23.0.jar;%APP_HOME%\lib\httpclient-4.5.6.jar;%APP_HOME%\lib\Base_JAR-9.2.2.2.jar;%APP_HOME%\lib\JdeNet_JAR-9.2.2.2.jar;%APP_HOME%\lib\ManagementAgent_JAR-9.2.2.2.jar;%APP_HOME%\lib\System_JAR-9.2.2.2.jar;%APP_HOME%\lib\jmxremote_optional-9.2.2.2.jar;%APP_HOME%\lib\jmxri-9.2.2.2.jar;%APP_HOME%\lib\xmlparserv2-9.2.2.2.jar;%APP_HOME%\lib\xercesImpl-2.12.0.jar;%APP_HOME%\lib\cantara-core-5.1.9-SNAPSHOT.jar;%APP_HOME%\lib\javax.mail-api-1.6.2.jar;%APP_HOME%\lib\commons-vfs2-2.4.1.jar;%APP_HOME%\lib\commons-httpclient-3.1.jar;%APP_HOME%\lib\jsch-0.1.55.jar;%APP_HOME%\lib\netty-all-4.1.39.Final.jar;%APP_HOME%\lib\mongodb-driver-3.8.0.jar;%APP_HOME%\lib\mongodb-driver-async-3.8.0.jar;%APP_HOME%\lib\txw2-2.3.1.jar;%APP_HOME%\lib\istack-commons-runtime-3.0.7.jar;%APP_HOME%\lib\stax-ex-1.8.jar;%APP_HOME%\lib\FastInfoset-1.2.15.jar;%APP_HOME%\lib\httpcore-4.4.10.jar;%APP_HOME%\lib\commons-codec-1.13.jar;%APP_HOME%\lib\xml-apis-1.4.01.jar;%APP_HOME%\lib\commons-text-1.8.jar;%APP_HOME%\lib\commons-lang3-3.9.jar;%APP_HOME%\lib\commons-io-2.6.jar;%APP_HOME%\lib\jcl-over-slf4j-1.7.28.jar;%APP_HOME%\lib\log4j-slf4j-impl-2.12.1.jar;%APP_HOME%\lib\async-http-client-1.9.32.jar;%APP_HOME%\lib\slf4j-api-1.7.28.jar;%APP_HOME%\lib\jackson-jaxrs-json-provider-2.9.6.jar;%APP_HOME%\lib\jackson-jaxrs-xml-provider-2.9.6.jar;%APP_HOME%\lib\jackson-dataformat-xml-2.9.6.jar;%APP_HOME%\lib\jackson-module-jaxb-annotations-2.9.6.jar;%APP_HOME%\lib\jackson-datatype-jsr310-2.9.6.jar;%APP_HOME%\lib\jackson-jaxrs-base-2.9.6.jar;%APP_HOME%\lib\jackson-databind-2.9.6.jar;%APP_HOME%\lib\jackson-annotations-2.9.6.jar;%APP_HOME%\lib\jackson-dataformat-yaml-2.9.6.jar;%APP_HOME%\lib\log4j-core-2.12.1.jar;%APP_HOME%\lib\log4j-api-2.12.1.jar;%APP_HOME%\lib\AIS_Client-2.0.3.jar;%APP_HOME%\lib\guava-23.0.jar;%APP_HOME%\lib\mongodb-driver-core-3.8.0.jar;%APP_HOME%\lib\bson-3.8.0.jar;%APP_HOME%\lib\jackson-core-2.9.6.jar;%APP_HOME%\lib\woodstox-core-asl-4.4.1.jar;%APP_HOME%\lib\woodstox-core-5.0.3.jar;%APP_HOME%\lib\stax2-api-3.1.4.jar;%APP_HOME%\lib\snakeyaml-1.18.jar;%APP_HOME%\lib\netty-3.10.5.Final.jar;%APP_HOME%\lib\jsr305-1.3.9.jar;%APP_HOME%\lib\error_prone_annotations-2.0.18.jar;%APP_HOME%\lib\j2objc-annotations-1.1.jar;%APP_HOME%\lib\animal-sniffer-annotations-1.14.jar;%APP_HOME%\lib\guava-jdk5-17.0.jar;%APP_HOME%\lib\stax-api-1.0-2.jar

@rem Execute cantara-upgrade
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %CANTARA_UPGRADE_OPTS%  -classpath "%CLASSPATH%" com.rinami.cantara.upgrade.CantaraUpgrade %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable CANTARA_UPGRADE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if  not "" == "%CANTARA_UPGRADE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
