Tuesday, September 30, 2008

Studies --> java --> Ejb -> Simple build file to create EAR

This is simple example to create a ear file through build. We need to create some folder structures .

1). build.xml





















































































2). build.bat
@rem build\build.bat@echo off
call .\setenv.bat:: let's just make sure WSROOT is valid, (if is not, an error message was already given)if not exist %WSROOT%\jmetro\build\build.bat goto done
@rem Get command line arguments. Supports variable number of argumentsset CMD_LINE_ARGS=%1if ""%1""=="""" ( echo WSROOT=%WSROOT% echo JAVA_HOME=%JAVA_HOME% echo ANT_HOME=%ANT_HOME% %JAVA_HOME%\bin\java -version goto doneArgs)shift
:copyPropertiesFileif "%TARGET_APPSERVER%"=="" ( set TARGET_APPSERVER=weblogic)@copy /y ..\config\%TARGET_APPSERVER%\build.properties build.properties
:setupArgsif ""%1""=="""" goto doneArgsset CMD_LINE_ARGS=%CMD_LINE_ARGS% %1shiftgoto setupArgs
:doneArgscall %ANT_HOME%\bin\ant %CMD_LINE_ARGS%echo ant_home = %ANT_HOME%:done

3) setenv.bat
@rem Sets environment variables@echo off:: WSROOT should point to the parent directory of jmetro and jmetrotest:: set WSROOT=G:\MyProject <-- this use to be the original WSROOTif "%WSROOT%" == "" ( for /f "tokens=1,2 delims=\" %%i in ('cd') do set WSROOT=%%i\%%j)
if exist %WSROOT%\builda\build.bat goto done
:: this is for backwards compatibility, where WSROOT used to point to:: the parent of the parent of jmetro and jmetrotestif exist %WSROOT%\metrodev\jmetro\build\build.bat goto oldStyle
echo There seems to be a problem with your environment variable WSROOTecho Make sure it points to the parent directory of jmetro and jmetrodevgoto done
:oldStyleset WSROOT=E:\metrodev\tools
:done
set JMTOOLS=%WSROOT%\tools
set ANT_HOME=%JMTOOLS%\antset JAVA_HOME=%JMTOOLS%\jvm\jdk150
set XMLBEANS_HOME=%JMTOOLS%\xmlbeans-2.0.0set XMLBEANS_LIB=%XMLBEANS_HOME%\lib
set CLASSPATH=%XMLBEANS_LIB%;%CLASSPATH%
:: Make sure our tools are the first ones in the pathfor %%i in (java.exe) do set java.exe=%%~$PATH:iif /i "%java.exe%" neq "%JAVA_HOME%\bin\java.exe" ( echo Adding %JAVA_HOME%\bin;%ANT_HOME%\bin;%JMTOOLS%\misc to PATH path %JAVA_HOME%\bin;%ANT_HOME%\bin;%JMTOOLS%\misc;%path%)


In above .bat file some properties are unncessary. we need to cpoy the tools directory with
ant , jvm, perl and xml beans 2.0. I think except ant all are not necessary.

No comments: