Hans Dockter wrote:
Hi,
I have hit upon a current dir issue when porting a Maven build to
Gradle. Maven seems to change the current dir to the sub project it is
actual building. Some test classes in this subproject rely on this as
they use relative paths. Whether this is a design smell is one
question. The other question is if Gradle should also change the
current dir to the project dir of the task it is executing?
Personally, I think that it is poor form to write builds or tests that
depend on the current directory of the process to be set to some
particular location.
Even if it were a good idea, it is difficult to implement. Lots of
things ignore the 'user.dir' property (FileInputStream for example), so
we'd need native code to do this properly. Or we'd need to fork a
process for each project. Or some bytecode weaving. Or something equally
nasty.
In addition, changing the process' current directory also limits our
options for running things in parallel. The same is true of setting
system properties on a per-project basis.
One thing that would be reasonable to do, is to set the working dir when
the tests are run in forked mode. In the case of test-ng we could also
inject a parameter which is set to the project dir. Another option would
be to provide some way for the tests to programatically ask gradle for
the project dir (and other details about the project), such as a static
method somewhere.
Adam
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email