开发者

Can't locate build.xml file when running ant through a shell script

I'm using bash shell running on Cygwin on Windows 7. I have this in my bash script, which attempts to figure out the location of a build file based on the location of the currently executing script …

SCRIPT_DIR="$( cd -P "$( dirname "$0" )" && pwd )"
BUILDFILE=$SCRIPT_DIR/build.xml
ant -buildfile $BUILDFILE -Dbuildtarget=$1 -Dmodule="$2" -Dproject=$3 -Dnolabel=true -DFirefox=$4 -DInternetExplorer=$5 -DGoogleChrome=$6 Selenium4

However, even though the file is there, I get an "Unable to locate buildfile error"

$ sh c:/selenium//run_client_tests.sh prod "\Critical Path\Live\QX" MyProj true false false
cygwin warning:
  MS-DOS style path detected: c:/selenium//run_client_tests.sh
  Pre开发者_如何学JAVAferred POSIX equivalent is: /cygdrive/c/selenium/run_client_tests.sh
  CYGWIN environment variable option "nodosfilewarning" turns off this warning.
  Consult the user's guide for more details about POSIX paths:
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
Started script
Buildfile: \cygdrive\c\selenium\build.xml does not exist!
Build failed

ls reveals the file is there …

dev@selenium_w7 /cygdrive/c/selenium
$ ls /cygdrive/c/selenium/build.xml
/cygdrive/c/selenium/build.xml

dev@selenium_w7 /cygdrive/c/selenium
$ ls c:/selenium/build.xml
c:/selenium/build.xml


The problem here is that ant does not know about Cygwin-style paths. Note that ant is complaining that it cannot find \cygdrive\c\selenium\build.xml. That is because /cygwin is only understood by the Cygwin shell.

What you need to do is pass a DOS-style path to ant. So replace

BUILDFILE=$SCRIPT_DIR/build.xml

with

BUILDFILE=`cygpath -w $SCRIPT_DIR/build.xml`

Or to make this a bit more platform-agnostic, use Java-style paths

BUILDFILE=`cygpath -m $SCRIPT_DIR/build.xml`
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜