You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Stefan Bodewig <bo...@bost.de> on 2000/06/09 14:58:02 UTC

Why doesn't Exec always cd on Windows?

Hi,

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?

Stefan