Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always interpret basedir as relative to project's root #668

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Upgrading from Phing 2.x to 3.0
===============================

This document aims to summarize all the breaking changes and noteworthy things
that you might stumble across when upgrading from Phing 2.x to 3.0.

* Omitting the `basedir` property in the root `project` tag now means "." instead
of the current working directory. This effectively reverts the change made in
http://www.phing.info/trac/ticket/309 (#668)
2 changes: 1 addition & 1 deletion classes/phing/parser/ProjectHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function init($tag, $attrs)
if ($f->isAbsolute()) {
$project->setBasedir($baseDir);
} else {
$project->setBaseDir($project->resolveFile($baseDir, new PhingFile(getcwd())));
$project->setBaseDir($project->resolveFile($baseDir, $buildFileParent));
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion docs/docbook5/en/source/appendixes/factsheet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@
</row>
<row>
<entry><literal>project.basedir</literal></entry>
<entry>The current project basedir.</entry>
<entry>The absolute path to the current project's basedir. The basedir is the
"root" of the project, e. g. the directory that was created when
cloning your project from version control. The basedir can be specified
by using a path relative to your buildfile by setting the <literal>basedir</literal>
attribute in your buildfile's root <literal>project</literal> tag.</entry>
</row>
<row>
<entry><literal>user.home</literal></entry>
Expand Down
5 changes: 2 additions & 3 deletions docs/docbook5/en/source/appendixes/projcomponents.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@
<row>
<entry><literal>basedir</literal></entry>
<entry><literal role="type">String</literal></entry>
<entry>The base directory of the project, i.e. the directory all paths
are relative to.</entry>
<entry>n/a</entry>
<entry>A relative path from the buildfile to the project's base directory. The resulting directory is stored in the <literal>project.basedir</literal> property as an absolute path.</entry>
<entry><literal>.</literal></entry>
<entry>No</entry>
</row>
<row>
Expand Down
10 changes: 6 additions & 4 deletions docs/docbook5/en/source/chapters/gettingstarted.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,12 @@
</row>
<row>
<entry><literal>basedir</literal></entry>
<entry>The base directory of the project, use &quot;.&quot; do denote
the current directory. <emphasis role="bold">Note:</emphasis> if
none is specified, the parent directory of the build file is
used!</entry>
<entry>The base directory of the project. This attribute controls the value of the
<literal>${project.basedir}</literal> property which can be used to reference
files with paths relative to the project root folder. Can be a path relative to
the position of the buildfile itself. If omitted, &quot;.&quot; will be used,
which means that the build file should be located in the project's root folder.
</entry>
<entry>No</entry>
</row>
<row>
Expand Down
30 changes: 30 additions & 0 deletions test/classes/phing/regression/309/Ticket309RegressionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

use \Phing\Test\AbstractBuildFileTest;

class Ticket309RegressionTest extends AbstractBuildFileTest {

/**
* The project.basedir property denotes the project root directory.
* This root directory can be set by the "basedir" attribute on the
* <project> tag. It denotes the path to the project root, relative to
* the buildfile.
*
* The default is ".", meaning that the build.xml file is locate in the
* project root.
*
* This test uses several buildfiles that reference the /etc/regression/309
* directory as their project root in various ways.
*/
public function testPhingCallTask()
{
$testBasedir = PHING_TEST_BASE . "/etc/regression/309";

foreach (array('basedir-dot.xml', 'basedir-default.xml', 'sub/basedir-dotdot.xml') as $buildfile) {
$this->configureProject("$testBasedir/$buildfile");
$this->executeTarget("main");
$this->assertInLogs("project.basedir: $testBasedir");
}
}

}
9 changes: 9 additions & 0 deletions test/etc/regression/309/basedir-default.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<project name="test" default="main">

<target name="main">
<echo>project.basedir: ${project.basedir}</echo>
<echo>application.startdir: ${application.startdir}</echo>
</target>

</project>
9 changes: 9 additions & 0 deletions test/etc/regression/309/basedir-dot.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<project name="test" default="main" basedir=".">

<target name="main">
<echo>project.basedir: ${project.basedir}</echo>
<echo>application.startdir: ${application.startdir}</echo>
</target>

</project>
9 changes: 9 additions & 0 deletions test/etc/regression/309/sub/basedir-dotdot.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<project name="test" default="main" basedir="..">

<target name="main">
<echo>project.basedir: ${project.basedir}</echo>
<echo>application.startdir: ${application.startdir}</echo>
</target>

</project>