Skip to content

Commit

Permalink
Fixes #567 - allow creating relative symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
mrook committed Nov 9, 2016
1 parent d9bdc45 commit 59de41b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
29 changes: 28 additions & 1 deletion classes/phing/tasks/ext/SymlinkTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ class SymlinkTask extends Task
*/
private $_overwrite = false;

/**
* Whether to create relative symlinks
*
* @var boolean
*/
private $relative = false;

/**
* setter for _target
*
Expand Down Expand Up @@ -133,6 +140,14 @@ public function setOverwrite($overwrite)
$this->_overwrite = $overwrite;
}

/**
* @param boolean $relative
*/
public function setRelative($relative)
{
$this->relative = $relative;
}

/**
* getter for _target
*
Expand Down Expand Up @@ -183,6 +198,14 @@ public function getOverwrite()
return $this->_overwrite;
}

/**
* @return boolean
*/
public function isRelative()
{
return $this->relative;
}

/**
* Generates an array of directories / files to be linked
* If _filesets is empty, returns getTarget()
Expand Down Expand Up @@ -212,7 +235,11 @@ protected function getMap()
throw new BuildException('Link must be an existing directory when using fileset');
}

$fromDir = $fs->getDir($this->getProject())->getAbsolutePath();
if ($this->isRelative()) {
$fromDir = $fs->getDir($this->getProject())->getPath();
} else {
$fromDir = $fs->getDir($this->getProject())->getAbsolutePath();
}

if (!is_dir($fromDir)) {
$this->log('Directory doesn\'t exist: ' . $fromDir, Project::MSG_WARN);
Expand Down
7 changes: 7 additions & 0 deletions docs/docbook5/en/source/appendixes/optionaltasks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13047,6 +13047,13 @@ host="webserver" command="ls" /></programlisting>
<entry><literal>false</literal></entry>
<entry>No</entry>
</row>
<row>
<entry><literal>relative</literal></entry>
<entry><literal role="type">Boolean</literal></entry>
<entry>Whether to create relative symlinks</entry>
<entry><literal>false</literal></entry>
<entry>No</entry>
</row>
</tbody>
</tgroup>
</table>
Expand Down

0 comments on commit 59de41b

Please sign in to comment.