Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a custom Phing task to extract the MantisBT version
Affects #11339: Create installable archive
- Loading branch information
Showing
2 changed files
with
66 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
# MantisBT - a php based bugtracking system | ||
|
||
# MantisBT is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# MantisBT is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with MantisBT. If not, see <http://www.gnu.org/licenses/>. | ||
require_once('phing/Task.php'); | ||
|
||
/** | ||
* The <tt>ExtractMantisBTVersion</tt> is a custom task which extracts the MantisBT version | ||
* as defined by the constants file. | ||
* | ||
* @author Robert Munteanu | ||
*/ | ||
class ExtractMantisBTVersion extends Task { | ||
|
||
private $file; | ||
|
||
public function setFile(PhingFile $file) { | ||
|
||
$this->file = $file; | ||
} | ||
|
||
public function main() { | ||
|
||
if ( ! isset ( $this->file ) ) { | ||
throw new BuildException("Missing 'file' attribute."); | ||
} | ||
|
||
$contents = file($this->file->getPath()); | ||
|
||
foreach ( $contents as $line ) { | ||
if ( strstr($line, 'MANTIS_VERSION')) { | ||
eval($line); | ||
break; | ||
} | ||
} | ||
|
||
if ( !constant('MANTIS_VERSION' ) ) | ||
throw new BuildException('No constant named MANTIS_VERSION found in ' . $this->file->getPath()); | ||
|
||
$this->project->setProperty('mantisbtversion', MANTIS_VERSION); | ||
} | ||
} | ||
?> |