@echo off

REM ----------------------------------------------------------
REM Jetspeed Build Script
REM This script is tested under Windows NT & Win98
REM ----------------------------------------------------------

setlocal

REM ---------------------------------------------------
REM Modify the following to change the default settings
REM The defaults should be OK for all configurations
REM ---------------------------------------------------

REM -- root directory for the project
set _PROJECTDIR=%PROJECTDIR%
set PROJECTDIR=..

REM -- Directory containing jars required for runtime
set _LIBDIR=%LIBDIR%
set LIBDIR=%PROJECTDIR%\lib

REM -- Directory containing jars required for compilation
set _BUILDDIR=%BUILDDIR%
set BUILDDIR=%PROJECTDIR%\build\lib

REM -- Name of the build file to use
set _BUILDFILE=%BUILDFILE%
set BUILDFILE=build.xml

REM -- External dependencies jar required for building this project
set _JAR_DEPENDENCIES=%JAR_DEPENDENCIES%
set JAR_DEPENDENCIES="%PROJECTDIR%\..\jakarta-site2\lib\jdom*.jar"

REM --------------------------------------------
REM No need to edit anything past here
REM --------------------------------------------

:init
set _CLASSPATH=%CLASSPATH%
set LOCALPATH=

:buildpath
for %%l IN (%LIBDIR%\*.jar) DO call setlocalpath %%l
for %%l IN (%BUILDDIR%\*.jar) DO call setlocalpath %%l
for %%l IN (%JAR_DEPENDENCIES%) DO call setlocalpath %%l

:testjavahome
if "%JAVA_HOME%" == "" goto setjavahome
goto build

:setjavahome
if not "%OS%" == "Windows_NT" goto javahomeerror

:setjavahoment
for %%j IN (java.exe) DO set JAVABIN=%%~dp$PATH:j
if "%JAVABIN%" == "" goto javahomeerror
for %%j IN (%JAVABIN%..\) DO set JAVA_HOME=%%~dpj

:build
if exist %JAVA_HOME%\lib\tools.jar set CLASSPATH=%CLASSPATH%;%JAVA_HOME%\lib\tools.jar

%JAVA_HOME%\bin\java.exe -classpath "%CLASSPATH%;%LOCALPATH%" org.apache.tools.ant.Main -buildfile %BUILDFILE% %1 %2 %3 %4 %5 %6 %7 %8 %9 

goto end

:javahomeerror
echo ERROR: JAVA_HOME not found in your environment.
echo Please, set the JAVA_HOME variable in your environment to match the
echo location of the Java Virtual Machine you want to use.

:end

set CLASSPATH=%_CLASSPATH%
set PROJECTDIR=%_PROJECTDIR%
set LIBDIR=%_LIBDIR%
set BUILDDIR=%_BUILDDIR%
set BUILDFILE=%_BUILDFILE%
set JAR_DEPENDENCIES=%_JAR_DEPENDENCIES%

endlocal
