<?xml version="1.0"?>
<project name="projectname" default="build.local" basedir=".">
    <description>
        Build file for Your Project
 
        Please review property files to verify paths are correct before using!
 
        Available Tasks:
        - build.local - will deploy files locally (useful for testing)
        - build.development - will push files to development
        - build.production - not defined yet
    </description>
 
    <!-- load additional tasks -->
    <taskdef name="query" classname="com.jera.anttasks.Query"/>
    <typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpath="svnant.jar"/>
    <taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask"/>
 
    <property file="${user.name}.properties"/>
    <property file="build.properties"/>
    <property name="version" value="1.0"/>
 
    <!-- These will not be copied from the SVN export - these will not be pushed to production -->
    <patternset id="deployment.exclude">
        <exclude name="**/_build/**"/>
        <exclude name="**/_project/**"/>
        <exclude name="**/tests/**"/>
        <exclude name="**/_notes/**"/>
        <exclude name="**/thumbs.db"/>
    </patternset>
 
    <!-- These will not be deleted from production during deployment! If you have directories where site users upload content - list them here! -->
    <patternset id="production.exclude">
        <!-- <exclude name="**/docs/**"/> -->
    </patternset>
 
    <target name="-init" depends="-clean">
        <tstamp prefix="ts">
            <format property="today" pattern="MM/dd/yyyy"/>
        </tstamp>
        <echo>
            Creating: ${path.dist} and ${path.local}
        </echo>
        <mkdir dir="${path.build}"/>
        <mkdir dir="${path.local}"/>
    </target>
 
    <target name="-clean">
        <echo>
            Doing initial clean up before deployment...
            Deleting: ${path.dist} and ${path.local}
        </echo>
        <delete dir="${path.build}"/>
        <delete dir="${path.local}"/>
    </target>
 
    <target name="build.local" depends="-init">
        <echo>
            Preparing to build.local...
            * Building in ${path.dist}
            * Deploying to ${path.local}
        </echo>
        <dist svnpath="trunk"/>
        <prepare-dist version="local"/>
        <move-code dest="local"/>
    </target>
 
    <target name="build.development" depends="-init">
        <dist svnpath="trunk"/>
        <prepare-dist version="Development"/>
        <move-code dest="development"/>
        <!--<reload server="${server.development}" />-->
    </target>
 
    <target name="build.demo" depends="-init">
        <dist svnpath="demo"/>
        <prepare-dist version="Development" projectname="credtrakdemo"/>
        <move-code dest="demo"/>
    </target>
 
    <!--
    <target name="BUILD-PRODUCTION" depends="-init,-make-staging-branch">
    <dist svnpath="staging"/>
    <prepare-dist mode="true"/>
    <move-code dest="production"/>
 
    <svn-move src="${svn.staging}" dest="${svn.tags}${version}" message="creating a release tag for version ${version}."/>
    <reload server="${server.development}" />
 
    </target>
    -->
 
    <target name="-make-staging-branch">
        <svn-move src="${svn.trunk}" dest="${svn.staging}" message="creating a staging branch."/>
    </target>
 
    <macrodef name="move-code">
        <attribute name="dest"/>
        <attribute name="src" default="${path.dist}"/>
        <sequential>
            <echo>
                Delete existing files and copy new files to: '${path.@{dest}}' folder
            </echo>
 
            <delete includeemptydirs="true" failonerror="false">
                <fileset dir="${path.@{dest}}" includes="**/*">
                    <patternset refid="production.exclude"/>
                </fileset>
            </delete>
            <copy todir="${path.@{dest}}">
                <fileset dir="${path.dist}">
                    <patternset refid="deployment.exclude"/>
                </fileset>
            </copy>
 
        </sequential>
    </macrodef>
 
    <macrodef name="prepare-dist" description="Modify files for production (set framework modes, etc)">
        <attribute name="path" default="${path.dist}"/>
        <attribute name="mode" default="false"/>
        <attribute name="version" default="${version}"/>
        <attribute name="lastmodifieddate" default="${ts.today}"/>
        <attribute name="projectname" default="credtrak"/>
        <sequential>
            <echo>
                Modify files: @{path}/config/ColdSpring.xml
                * Setting Model-Glue reload to: @{mode}
                * Setting Model-Glue debug to: @{mode}
                * Setting Model-Glue rescaffold to: @{mode}
                * Setting Model-Glue generationenabled to: @{mode}
                * Adding the last modified date as ${ts.today}
                * Adding the version as @{version}
            </echo>
            <xmltask outputter="simple:4" source="@{path}/config/ColdSpring.xml" dest="@{path}/config/ColdSpring.xml">
                <replace path="//property[@name='reload']/value/text()" withText="@{mode}"/>
                <replace path="//property[@name='debug']/value/text()" withText="@{mode}"/>
                <replace path="//property[@name='rescaffold']/value/text()" withText="@{mode}"/>
                <replace path="//property[@name='generationEnabled']/value/text()" withText="@{mode}"/>
            </xmltask>
 
            <echo>
                Setting correct project name ( @{projectname} ) in:
                * @{path}/config/*.xml
                * @{path}/controller/*.cfc
                * Application.cfc
            </echo>
            <!-- <replace file="@{path}/config/ColdSpring.xml" token="credtrak" value="@{projectname}" /> -->
 
            <replace dir="@{path}/config" token="credtrak" value="@{projectname}">
                <include name="*.xml"/>
            </replace>
 
            <replace dir="@{path}/controller" token="credtrak" value="@{projectname}">
                <include name="*.cfc"/>
            </replace>
 
            <replace file="@{path}/Application.cfc" token="credtrak" value="@{projectname}"/>
        </sequential>
    </macrodef>
 
    <macrodef name="dist" description="Export project files from SVN to local build directory.">
        <attribute name="svnpath"/>
        <attribute name="distpath" default="${path.dist}"/>
        <sequential>
            <echo>
                Exporting '${svn.@{svnpath}}' to '${path.dist}'
            </echo>
            <svn>
                <export srcurl="${svn.@{svnpath}}" destpath="${path.dist}"/>
            </svn>
        </sequential>
    </macrodef>
 
    <macrodef name="reload" description="Reload Fusebox framework. Requires 'wget' be installed locally">
        <attribute name="server"/>
        <sequential>
            <query message="Please enter your password" name="login.password" password="true"/>
            <echo message="Fusebox LoadClean on @{server}"/>
            <exec executable="wget" outputproperty="wget.output" resultproperty="wget.result">
                <arg line="${server.development}?fusebox.loadclean=true&amp;fusebox.password=${fusebox.password} --http-user=${login.username} --http-passwd=${login.password} --spider -d --no-check-certificate"/>
            </exec>
            <echo message="Fusebox ParseAll on @{server}"/>
            <exec executable="wget" outputproperty="wget.output" resultproperty="wget.result">
                <arg line="${server.development}?fusebox.parseall=true&amp;fusebox.password=${fusebox.password} --http-user=${login.username} --http-passwd=${login.password} --spider -d --no-check-certificate"/>
            </exec>
        </sequential>
    </macrodef>
 
    <macrodef name="svn-move" description="This macrodef will move svn project into another location. It will also try to delete the dest if it already exists.">
        <!-- required attributes -->
        <attribute name="src"/>
        <attribute name="dest"/>
        <attribute name="message"/>
        <sequential>
            <echo>
                SVN move "@{src}" to "@{dest}"
            </echo>
            <trycatch>
                <try>
                    <svn>
                        <delete url="@{dest}" message="deleting"/>
                    </svn>
                </try>
                <catch>
                </catch>
            </trycatch>
            <svn javahl="false">
                <copy srcUrl="@{src}" destUrl="@{dest}" message="@{message}"/>
            </svn>
        </sequential>
    </macrodef>
 
    <macrodef name="applyregex" description="a utitlity task for regular exression based substitution.">
        <!-- required attributes -->
        <attribute name="file"/>
        <attribute name="pattern"/>
        <attribute name="expression"/>
        <sequential>
            <echo>
                @{file}
            </echo>
            <replaceregexp match="@{pattern}" replace="@{expression}" flags="igm">
                <fileset file="@{file}"/>
            </replaceregexp>
        </sequential>
    </macrodef>
 
</project>
/home3/thecrumb/public_html/wiki/data/pages/ant/build.txt · Last modified: 2010/11/11 12:22 by thecrumb
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki