@echo off
setlocal

rem Load arguments in a compatible way
set ARGS=
:startArgs
if "%1" == "" goto endArgs
set ARGS=%ARGS% %1
shift
goto startArgs
:endArgs

set _HERE=.
set _LIBS=%_HERE%\_shared\3rdparty
set ORIG_ANT_HOME=%_LIBS%\ant\1.6beta

rem Setup new ANT for a new classpath
set ANT_HOME=%_LIBS%\ant\.tmp
set ANT_LIB=%ANT_HOME%\lib
if EXIST %ANT_HOME% del /S/Q %ANT_HOME%
mkdir %ANT_HOME%
xcopy %ORIG_ANT_HOME%\* %ANT_HOME%\. /S/E/Q

copy %_LIBS%\bcel\5.1\bcel-5.1.jar %ANT_LIB%\.
copy %_LIBS%\junit\3.8.1\junit.jar %ANT_LIB%\.

rem For Xalan, we need to ensure the right one is used.
copy %_LIBS%\xalan\2.5.1\xalan.jar %ANT_LIB%\.
copy %_LIBS%\xerces\2.4.0\xml-apis.jar %ANT_LIB%\.
copy %_LIBS%\xerces\2.4.0\xercesImpl.jar %ANT_LIB%\.

set BOOTPATH=%ANT_LIB%\xalan.jar;%ANT_LIB%\xml-apis.jar;%ANT_LIB%\xercesImpl.jar

if "%ANT_OPTS%" == "" goto setOpts
set ANT_OPTS=%ANT_OPTS% -Xbootclasspath/p:%BOOTPATH%
goto start

:setOpts
set ANT_OPTS=-Xbootclasspath/p:%BOOTPATH%

goto start

:start

call %ANT_HOME%\bin\ant.bat %ARGS%

endlocal
