<?xml version="1.0" encoding="UTF-8"?>
<project name="JCE Popups Extension" basedir="." default="build">
    <property description="Package Version" name="package_version" value="204" />
    <property description="Version" name="version" value="2.0.4" />
    <property description="Plugin Name" name="name" value="WidgetKit" />
    <property description="Plugin Name" name="extension_type" value="popups" />
    <property description="Plugin Name" name="extension_name" value="widgetkit" />
    
    <property description="Language directory" name="lang_dir" value="../../../../../language/en-GB" />
    <property description="Export directory" name="export_dir" value="/Users/ryandemmer/Releases/plugins/" />
    <property description="E-mail" name="e-mail" value="info@joomlacontenteditor.net" />
    <property description="Licence" name="licence" value="GNU/GPL Version 2 - http://www.gnu.org/licenses/gpl-2.0.html" />
    <property description="Copyright" name="copyright" value="Copyright (C) 2006 - 2012 Ryan Demmer. All rights reserved" />
    
    <target name="ant" description="Builds the project">

        <taskdef name="jsmin"
                 classname="net.matthaynes.jsmin.JSMin_Task"
                 classpath="../../../../../../../ant-tools/jsmin.jar"/>
        
        <tstamp>
            <format property="DATE" pattern="dd MMMM yyyy" />
        </tstamp>

        <delete dir="${export_dir}/${extension_name}/${package_version}"
                quiet="true" />
        <delete file="${export_dir}/jce_${extension_type}_${extension_name}_${package_version}.zip"
                quiet="true" />

        <copy todir="${export_dir}/${extension_name}/${package_version}/">
            <fileset dir="." defaultexcludes="yes">
                <include name="${extension_name}.php" />
                <include name="${extension_name}.xml" />
                <include name="${extension_name}/" />
                <exclude name="build.xml" />
                <exclude name=".project" />
                <exclude name=".settings" />
                <exclude name=".buildpath" />
                <exclude name=".externalToolBuilders/" />
                <exclude name="**.project" />
                <exclude name="**.settings" />
                <exclude name="*.settings" />
                <exclude name="**.settings/" />
                <exclude name="**.buildpath" />
                <exclude name="**.externalToolBuilders/" />
                <exclude name="changelog.txt" />
                <exclude name="README" />
                <exclude name="**/nbproject" />
                <exclude name="**/nbproject/**" />
            </fileset>
            <fileset dir="${lang_dir}">
                <include name="en-GB.com_jce_${extension_type}_${extension_name}.ini" />
            </fileset>
        </copy>

        <!-- Load Header file -->
        
        <loadfile property="header" srcFile="../../../../../administrator/components/com_jce/header.txt"/>
        <loadfile property="header_tinymce" srcFile="../../../../../administrator/components/com_jce/header_tinymce.txt"/>
        
        <!-- JSMin -->
        
        <jsmin force="true" copyright="${header_tinymce}">
            <fileset dir="${export_dir}/${extension_name}/${package_version}">
                <contains text="http://tinymce.moxiecode.com/license" />          
                <include name="**/*.js" />
            </fileset>
        </jsmin>
        
        <jsmin force="true" copyright="${header}">
            <fileset dir="${export_dir}/${extension_name}/${package_version}">                
                <include name="**/*.js" />                
                <not>
                    <contains text="http://tinymce.moxiecode.com/license" />
                </not>
            </fileset>
        </jsmin>
        
        <replace 
            dir="${export_dir}/${extension_name}/${package_version}/">
            <replacefilter 
                token="JCE Editor" 
                value="${name}"/>
            <replacefilter 
                token="2.3.2.3" 
                value="${version}"/>
            <replacefilter 
                token="info@joomlacontenteditor.net" 
                value="${e-mail}"/>
            <replacefilter 
                token="11 March 2013" 
                value="${DATE}"/>
            <replacefilter 
                token="GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html" 
                value="${licence}"/>
            <replacefilter 
                token="Copyright (C) 2006 - 2013 Ryan Demmer. All rights reserved" 
                value="${copyright}"/>
        </replace>
        
        <!--delete file="${export_dir}/${extension_name}/${package_version}/header.txt" quiet="true" />
        <delete file="${export_dir}/${extension_name}/${package_version}/header_tinymce.txt" quiet="true" /-->
        
        <zip destfile="${export_dir}/jce_${extension_type}_${extension_name}_${package_version}.zip"
             basedir="${export_dir}/${extension_name}/${package_version}/">
            <fileset dir="${export_dir}/${extension_name}/${package_version}/" />
        </zip>
    </target>
</project>