ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject Why doesn't Exec always cd on Windows?
Date Fri, 09 Jun 2000 12:58:02 GMT

Roderick Dunne has boiled down his problem he described in "Using
built in task ant with" to Exec not changing the directory into the
subproject's dir.

The problem is here:

        if (myos.toLowerCase().indexOf("windows") >= 0) {
-->         if (!dir.equals(project.resolveFile(".")))
                command = "cmd /c cd " + dir + " && " + command;

When executing an <ant> task, this sub-Ant gets it's basedir set to
the place where the build.xml resides and thus
project.resolveFile(".") returns the name of the subdirectory
allthough this is not the dir Ant has been called from.

Why is this check there in the first place? Can we savely remove the
check and everything's fine? Note I'm not too familiar with Windows if
this sounds like a dumb question.

The other solution - which wouldn't be hard to implement but involves
more changes - is to make Project know whether it has been
instantiated by Main or by an Ant task and change the line above to
something like

       if (!project.isTopLevel() || !dir.equals(project.resolveFile(".")))

What do you think?


View raw message