<?xml version="1.0" encoding="UTF-8" ?>

<project>
    <property file="build.properties" />

    <target name="textdomain">
        <!-- Add the feed-stats-plugin text domain to all of the PHP 
        files in this project using the apply task. -->
        <apply executable="php">
            <arg value="${wpi18n}/add-textdomain.php" />
            <arg value="-i" />
            <arg value="feed-stats-plugin" />
            <fileset dir="." includes="**/*.php" />
        </apply>
    </target>
    
    <target name="makepot">
        <!-- Run the WordPress i18n MakePOT utility. -->
        <exec executable="php">
            <arg value="${wpi18n}/makepot.php" />
            <arg value="wp-plugin" />
            <arg value="." />
        </exec>
    </target>
    
    <target name="cleanup">
        <fixcrlf srcdir="." includes="**/*.js" eol="asis" tab="remove"
            tablength="4" eof="asis" />
        <fixcrlf srcdir="." includes="**/*.xml" eol="asis" tab="remove"
            tablength="4" eof="asis" />
        <fixcrlf srcdir="." includes="**/*.html" eol="asis" tab="remove"
            tablength="4" eof="asis" />
        <fixcrlf srcdir="." includes="**/*.php" excludes="**/*simpletest*" 
            eol="asis" tab="remove" tablength="4" eof="asis" />
    </target>
    
    <target name="preptag">
        <!-- Create a new directory for this release. -->
        <exec executable="svn">
            <arg value="mkdir" />
            <arg value="../tags/${release}" />
        </exec>
        
        <!-- Copy all of the appropriate folders into the tag folder. -->
        <apply executable="svn">
            <arg value="cp" />
            <srcfile />
            <dirset dir=".">
                <include name="*" />
                <exclude name="tests" />
            </dirset>
            <arg value="../tags/${release}/" />
        </apply>
        
        <!-- Copy all of the appropriate files into the tag folder. -->
        <apply executable="svn">
            <arg value="cp" />
            <srcfile />
            <fileset dir=".">
                <include name="*.php" />
                <include name="changelog.txt" />
                <include name="copying.txt" />
                <include name="readme.txt" />
            </fileset>
            <arg value="../tags/${release}/" />
        </apply>
    </target>
    
    <target name="changelog" description="Prepares a MOAP-style changelog entry.">
        <exec executable="svn" vmlauncher="false" output="svnstatus.xml">
            <arg line="status --xml" />
        </exec>
        <echo message="Fetched version information."/>
        
        <tstamp>
            <format property="changelog.timestamp" pattern="yyyy-MM-dd" />
        </tstamp>
        
        <xslt in="svnstatus.xml" out="changelog-tmp.txt" style="changelog.xsl">
            <param name="timestamp" expression="${changelog.timestamp}"/>
            <param name="author" expression="${user.name}" />
        </xslt>
        
        <replace file="changelog-tmp.txt">
            <replacetoken><![CDATA[<?xml version="1.0" encoding="UTF-8"?>]]></replacetoken>
        </replace>
        
        <concat destfile="changelog-com.txt" fixlastline="true">
            <fileset file="changelog-tmp.txt" />
            <string><![CDATA[ ]]></string>
            <fileset file="changelog.txt" />
        </concat>
        <echo message="Generated template." />
        
        <delete file="changelog.txt" />
        <move file="changelog-com.txt" tofile="changelog.txt" />
        <delete file="changelog-tmp.txt" />
        <delete file="svnstatus.xml" />
        <echo message="Housekeeping complete." />
    </target>
</project>
