Phing 2.4 - basedir attribute
Phing 2.4 introduces some changes in the handling of the 'basedir' attribute in the 'project' tag in each build file.
In Ant (see http://ant.apache.org/manual/using.html) and Phing (<= 2.3.3), not specifying the basedir attribute means the same as basedir=".", namely the parent directory of the build file that is called. Adding basedir="." seems to be common practice in a lot of build files (esp. Ant), even though that only adds verbosity (and maybe clarity).
Since "." reflects the current working directory in other tools, this behavior was (in my mind anyway) ambigious. Now, there are three modes of using the basedir attribute:
- not specifying it; same behavior as before, basedir = parent dir of the build file
- specifiying "."; basedir = current working directory, i.e. the dir you started phing from
- specifying anything else; basedir = relative or absolute path lookup based on the current working directory
-- I think this behavior is broken.
The basedir is supposed to be a reference to the project's root. It can be specified as a relative path from the buildfile's perspective as the position of the build file within a project is known. A path relative to the buildfile stays correct when moving the project around, e. g. making version control checkouts into different locations. Specifying "." or not specifying it should mean basedir = directory containing the build file. Any other relative link should be relative to the buildfile. (FWIW, this is also the way Ant works.)
The current working directory should never be relevant. If you need it, use application.startdir instead of project.basedir to reference it. Buildfiles can thus decide if they want to work with the project they belong to (using project.basedir) or with the user's cwd (using application.startdir).
See the bug report, postings on phing-dev and phing-users regarding this question and share your thoughts on these lists.
The (new) behavior has been reverted as of change 1128 on the 2.5 branch in SVN.
-mp.
"Cannot redeclare class" solution
In a nutshell, the problem was "Cannot redeclare class" errors being caused by files including things from both the testing directory (build target) and the current working directory (sandbox).
The solution was to add the following line to my build.xml file:
<includepath classpath="${build.target.dir}:${php.classpath}" />
This simply made my target directory take precidence over my current working directory. Ideally the cwd would be completely excluded but I haven't figured that one out yet, so I'll leave that as an exercise left up to the reader ;)
Harlan Iverson
