Skip to content

Commit

Permalink
Use a custom Phing task to extract the MantisBT version
Browse files Browse the repository at this point in the history
Affects #11339: Create installable archive
  • Loading branch information
rombert committed Jul 29, 2011
1 parent 3b3400f commit 657d98b
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 5 deletions.
17 changes: 12 additions & 5 deletions build.xml
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="MantisBT" default="test">

<includepath classpath="phing/tasks"/>
<taskdef name="extractMantisBTVersion" classname="mantisbt.ExtractMantisBTVersion"/>

<target name="init">
<mkdir dir="build"/>
</target>
Expand Down Expand Up @@ -31,13 +35,16 @@
</target>

<target name="package" depends="init">
<tar destfile="build/mantisbt.tar.gz" compression="gzip">
<extractMantisBTVersion file="core/constant_inc.php"/>

<tar destfile="build/mantisbt-${mantisbtversion}.tar.gz" compression="gzip">
<fileset dir=".">
<!-- directories which should not be deployed -->
<exclude name="build/**"/>
<exclude name="doc/**"/>
<exclude name="docbook/**"/>
<exclude name="packages/**"/>
<exclude name="phing/**"/>
<exclude name="tests/**"/>

<!-- customisations and IDE settings -->
Expand All @@ -58,11 +65,11 @@
</fileset>
</tar>

<filehash file="build/mantisbt.tar.gz" hashtype="1" />
<echo file="build/mantisbt.tar.gz.sha1" msg="${filehashvalue}"/>
<filehash file="build/mantisbt-${mantisbtversion}.tar.gz" hashtype="1" />
<echo file="build/mantisbt-${mantisbtversion}.tar.gz.sha1" msg="${filehashvalue}"/>

<filehash file="build/mantisbt.tar.gz" hashtype="0" />
<echo file="build/mantisbt.tar.gz.md5" msg="${filehashvalue}"/>
<filehash file="build/mantisbt-${mantisbtversion}.tar.gz" hashtype="0" />
<echo file="build/mantisbt-${mantisbtversion}.tar.gz.md5" msg="${filehashvalue}"/>
</target>

<target name="clean">
Expand Down
54 changes: 54 additions & 0 deletions phing/tasks/mantisbt/ExtractMantisBTVersion.php
@@ -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);
}
}
?>

0 comments on commit 657d98b

Please sign in to comment.