因為唔同platfrom… 係linux/max 上可以行既shell script, 係windows 係可以用cygwin 去行 可惜, 如果用 eclipse > ant build , 個ant call *.sh 就出事 寫(translate)左一個好無聊既 batch script (被)玩左一個下午,就係因為唔識寫script, 同埋個help 係 %~dpnI 唔係 %%~dpnI …. 記錄一下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
::-----------------------------------------------------------:: :: CONFIGURATION SCRIPT :: :: Script copies file.type.{DEPLOY} to file.type :: Where {DEPLOY} is one of PRODUCTION|STAGING|QA|INTERNAL|DEV :: :: modify from config.sh to windows environment :: :: Author: Steve Chan steve.chan@pxxxxl.com.au :: $Id: config.bat,v 1.0 2009/01/07 13:24:57 steve Exp $ ::-----------------------------------------------------------:: :: check that we were supplied two parameters @ECHO OFF IF NOT (%1)==() SET DEST=%1 IF NOT (%2)==() SET DEPLOY=%2 ::@ECHO ON ECHO.DIR /b /s %DEST%*.%DEPLOY% :: copy all filenames with extension . to a temporary file DIR /b /s %DEST%\*.%DEPLOY% > tmp.out :: iterate through the filenames and copy to the filename root FOR /f %%I IN (tmp.out) DO ( ECHO.copy: %%I %%~dpnI COPY %%I %%~dpnI ) :: get rid of the temporary file del tmp.out |
part of maven.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
<goal name="config"> <echo>CONFIGURATION BUNDLE USED: ${configuration.bundle}</echo> <echo>${configuration.script} ${basedir} ${configuration.bundle}</echo> <!-- distinguish windows environment, using config.bat instead of config.sh --> <!-- orginal script--> <!-- <ant:exec dir="${basedir}" executable="sh"> <ant:arg line="${configuration.script} ${basedir} ${configuration.bundle}"/> --> <ant:condition property="os.windows.family"> <ant:os family="windows"/> </ant> <j:choose> <j:when test="${os.windows.family}"> <ant:exec dir="${basedir}" executable="cmd"> <ant:arg line="/c config.bat ${basedir} ${configuration.bundle}" /> <echo>Windows Environment: config.bat ${basedir} ${configuration.bundle}</echo> </ant:exec> </j:when> <j:otherwise> <ant:exec dir="${basedir}" executable="sh"> <ant:arg line="${configuration.script} ${basedir} ${configuration.bundle}" /> </ant:exec> </j:otherwise> </j:choose> <!-- end modification for windows environment --> </goal> |