Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <project name="groupofthingsFE" default="message" basedir=".">
- <description>build/deploy for groupofthings.com</description>
- <!-- set global properties for this build -->
- <!-- This reads from build.properties, which should NOT be tracked by version control. -->
- <!-- There is a template.build.properties that should be copied and modified for your environment. -->
- <propertyfile file="build.properties" comment="Build properties for ${ant.project.name}">
- <entry key="ssh_username" type="string" default=""/>
- <entry key="ssh_password" type="string" default=""/>
- <entry key="ssh_remote_host" type="string" default=""/>
- <entry key="production_db_name" type="string" default=""/>
- <entry key="production_db_user" type="string" default=""/>
- <entry key="production_db_pass" type="string" default=""/>
- <entry key="local_deploy" type="string" default="" />
- <entry key="remote_builds" type="string" default="" />
- <entry key="rivety_libs" type="string" default="" />
- </propertyfile>
- <loadproperties srcfile="build.properties" />
- <property name="dist" location="${basedir}/dist"/>
- <property name="rivety" location="${basedir}/../rivety"/>
- <property name="bootstrap" location="${basedir}/../bootstrap"/>
- <property name="themes" location="${basedir}/themes"/>
- <property name="modules" location="${basedir}/modules"/>
- <property name="etc" location="${basedir}/etc"/>
- <property name="build" location="${basedir}/build"/>
- <property name="tmp" location="${basedir}/tmp"/>
- <!-- commands -->
- <property name="chmod" location="/bin/chmod"/>
- <property name="phpunit" location="/usr/bin/phpunit"/>
- <property name="lessc" location="/home/jaybill/bin/lessc"/>
- <property name="yui-compressor" location="/usr/bin/yui-compressor"/>
- <!-- remote commands -->
- <property name="ln" value="/bin/ln"/>
- <property name="rm" value="/bin/rm"/>
- <!-- TARGET: local -->
- <!-- do a rivety build, copy config files in, deploy locally and then symlink the modules and themes folders -->
- <target name="local" depends="copylocal,linklibs,linksite,perms,lessc"></target>
- <!-- TARGET: copylocal -->
- <!-- do a rivety build and deploy it -->
- <target name="copylocal" depends="buildlocal" description="deploy local development build">
- <copy todir="${build}/etc">
- <fileset dir="${etc}" includes="${user.name}.config.ini"/>
- <filterset>
- <filter token="DBNAME" value="${local_db_name}"/>
- <filter token="DBUSER" value="${local_db_user}"/>
- <filter token="DBPASS" value="${local_db_pass}"/>
- </filterset>
- </copy>
- <move file="${build}/etc/${user.name}.config.ini" tofile="${build}/etc/config.ini"/>
- <!-- copy the whole thing to the web directory -->
- <symlink action="delete" link="${local_deploy}/modules/groupofthings"/>
- <symlink action="delete" link="${local_deploy}/themes/groupofthings"/>
- <symlink action="delete" link="${local_deploy}/lib/ZendFramework"/>
- <symlink action="delete" link="${local_deploy}/lib/Smarty"/>
- <symlink action="delete" link="${local_deploy}/lib/Asido"/>
- <delete dir="${local_deploy}"/>
- <mkdir dir="${local_deploy}"/>
- <copy todir="${local_deploy}">
- <fileset dir="${build}"/>
- </copy>
- </target>
- <!-- TARGET: linklibs -->
- <target name="linklibs">
- <!-- Zend Framework -->
- <exec executable="ln" >
- <arg value="-s"/>
- <arg value="${rivety_libs}/ZendFramework"/>
- <arg value="${local_deploy}/lib/ZendFramework"/>
- </exec>
- <!-- Smarty -->
- <exec executable="ln" >
- <arg value="-s"/>
- <arg value="${rivety_libs}/Smarty"/>
- <arg value="${local_deploy}/lib/Smarty"/>
- </exec>
- <!-- Asido -->
- <exec executable="ln" >
- <arg value="-s"/>
- <arg value="${rivety_libs}/Asido"/>
- <arg value="${local_deploy}/lib/Asido"/>
- </exec>
- </target>
- <!-- TARGET: copylibs -->
- <target name="copylibs">
- <!-- Zend Framework -->
- <copy todir="${build}/lib/ZendFramework">
- <fileset dir="${rivety_libs}/ZendFramework"/>
- </copy>
- <!-- Smarty -->
- <copy todir="${build}/lib/Smarty">
- <fileset dir="${rivety_libs}/Smarty"/>
- </copy>
- <!-- Asido -->
- <copy todir="${build}/lib/Asido">
- <fileset dir="${rivety_libs}/Asido"/>
- </copy>
- </target>
- <!-- TARGET: buildlocal -->
- <!-- do a rivety build in the build directory, putting all the config files in the right places. -->
- <target name="buildlocal">
- <!-- clear build -->
- <delete dir="${build}"/>
- <mkdir dir="${build}"/>
- <!-- rivety -->
- <copy todir="${build}/core">
- <fileset dir="${rivety}/core">
- <exclude name="**/frontend/**/*.gif"/>
- <exclude name="**/frontend/**/*.png"/>
- <exclude name="**/frontend/**/*.jpg"/>
- <exclude name="**/frontend/**/*.css"/>
- <exclude name="**/frontend/**/*.js"/>
- </fileset>
- </copy>
- <copy todir="${build}/errordocuments"><fileset dir="${rivety}/errordocuments"/></copy>
- <copy todir="${build}/etc"><fileset dir="${rivety}/etc"/></copy>
- <copy todir="${build}/lib"><fileset dir="${rivety}/lib"/></copy>
- <copy todir="${build}/logs"><fileset dir="${rivety}/logs"/></copy>
- <copy todir="${build}/modules"><fileset dir="${rivety}/modules"/></copy>
- <copy todir="${build}/themes"><fileset dir="${rivety}/themes"/></copy>
- <copy todir="${build}/tmp"><fileset dir="${rivety}/tmp"/></copy>
- <copy todir="${build}/uploads"><fileset dir="${rivety}/uploads"/></copy>
- <copy file="${rivety}/header.php" tofile="${build}/header.php"/>
- <copy file="${rivety}/index.php" tofile="${build}/index.php"/>
- <!-- remove cruft -->
- <!-- copy the config files to the right place -->
- <copy file="${etc}/.htaccess" tofile="${build}/.htaccess"/>
- <copy file="${etc}/crossdomain.xml" tofile="${build}/crossdomain.xml"/>
- <copy file="${etc}/maintenance.html" tofile="${build}/maintenance.html"/>
- <copy file="${etc}/robots.txt" tofile="${build}/robots.txt"/>
- <copy file="${etc}/google121d37862c3bd26a.html" tofile="${build}/google121d37862c3bd26a.html"/>
- </target>
- <!-- TARGET: buildsite -->
- <!-- copies the modules and themes to the rivety build. Generally only for deployment. -->
- <target name="buildsite" depends="lessc">
- <!-- modules -->
- <delete dir="${build}/modules"/>
- <mkdir dir="${build}/modules"/>
- <copy todir="${build}/modules">
- <fileset dir="${modules}"/>
- </copy>
- <!-- themes -->
- <delete dir="${build}/themes"/>
- <mkdir dir="${build}/themes"/>
- <copy todir="${build}/themes">
- <fileset dir="${themes}"/>
- </copy>
- </target>
- <!-- TARGET: copysite -->
- <!-- copies the modules and themes to the already locally deployed instance. Not direclty used. See the linksite target instead. -->
- <target name="copysite">
- <!-- modules -->
- <symlink action="delete" link="${local_deploy}/modules/groupofthings"/>
- <delete dir="${local_deploy}/modules"/>
- <mkdir dir="${local_deploy}/modules"/>
- <copy todir="${local_deploy}/modules">
- <fileset dir="${modules}"/>
- </copy>
- <!-- themes -->
- <symlink action="delete" link="${local_deploy}/themes/groupofthings"/>
- <delete dir="${local_deploy}/themes"/>
- <mkdir dir="${local_deploy}/themes"/>
- <copy todir="${local_deploy}/themes">
- <fileset dir="${themes}"/>
- </copy>
- </target>
- <!-- TARGET: linksite -->
- <!-- symlink workspace modules and themes to the locally deployed instance so changes don't have to be copied to be visible. -->
- <target name="linksite" description="deploy the modules and themes" >
- <!-- modules -->
- <exec executable="ln" >
- <arg value="-s"/>
- <arg value="${modules}/groupofthings"/>
- <arg value="${local_deploy}/modules/groupofthings"/>
- </exec>
- <!-- themes -->
- <exec executable="ln" >
- <arg value="-s"/>
- <arg value="${themes}/groupofthings"/>
- <arg value="${local_deploy}/themes/groupofthings"/>
- </exec>
- </target>
- <!-- set the correct permissions for locally deployed directories that need to be written to -->
- <target name="perms" description="sets local permissions on deployed code">
- <exec executable="${chmod}" >
- <arg value="-R"/>
- <arg value="0777"/>
- <arg value="${local_deploy}/tmp"/>
- </exec>
- <exec executable="${chmod}" >
- <arg value="-R"/>
- <arg value="0777"/>
- <arg value="${local_deploy}/logs"/>
- </exec>
- <exec executable="${chmod}" >
- <arg value="-R"/>
- <arg value="0777"/>
- <arg value="${local_deploy}/etc"/>
- </exec>
- </target>
- <!-- TARGET: deploy -->
- <!-- build the site, archive it and copy it to remote deployment server. This will NOT actually deploy the site, just copy it to the server. -->
- <target name="deploy" depends="buildlocal,copylibs,buildsite">
- <copy todir="${build}/etc">
- <fileset dir="${etc}" includes="production.config.ini"/>
- <filterset>
- <filter token="DBNAME" value="${production_db_name}"/>
- <filter token="DBUSER" value="${production_db_user}"/>
- <filter token="DBPASS" value="${production_db_pass}"/>
- </filterset>
- </copy>
- <move file="${build}/etc/production.config.ini" tofile="${build}/etc/config.ini"/>
- <!-- clear dist -->
- <delete dir="${dist}"/>
- <mkdir dir="${dist}"/>
- <tstamp/>
- <property name="distfile" value="${ant.project.name}-${DSTAMP}-${TSTAMP}.zip"/>
- <zip destfile="${dist}/${distfile}" basedir="${build}"/>
- <scp file="${dist}/${distfile}"
- todir="${ssh_username}@${ssh_remote_host}:${remote_builds}"
- password="${ssh_password}"/>
- <!-- remove symlink to old build -->
- <sshexec host="${ssh_remote_host}"
- username="${ssh_username}"
- password="${ssh_password}"
- trust="true"
- command="${rm} ${remote_builds}/current.zip"/>
- <!-- create symlink to new build -->
- <sshexec host="${ssh_remote_host}"
- username="${ssh_username}"
- password="${ssh_password}"
- trust="true"
- command="${ln} -s ${remote_builds}/${distfile} ${remote_builds}/current.zip"/>
- <!-- remove locally built code -->
- <delete dir="${build}"/>
- <delete dir="${dist}"/>
- </target>
- <!-- TARGET: props -->
- <!-- display all the properties ant sees, including the ones from this script. useful for debugging. -->
- <target name="props">
- <echoproperties/>
- </target>
- <!-- TARGET: test -->
- <!-- run the unit tests from the module -->
- <!-- please see README file in module/groupofthings/tests before using -->
- <target name="test">
- <echo message="Running PHPUnit/DBUnit tests. Please see module/groupofthings/tests/README if this doesn't work right."/>
- <exec executable="${phpunit}" >
- <arg value="--bootstrap=${local_deploy}/header.php"/>
- <arg value="${local_deploy}/modules/groupofthings/tests"/>
- </exec>
- </target>
- <!-- TARGET: lessc -->
- <!-- run lessc on the style.less file -->
- <target name="lessc">
- <echo message="Compiling LESS to CSS with lessc. "/>
- <echo message="Please see themes/groupofthings/frontend/less/README if this doesn't work right."/>
- <delete dir="${tmp}"/>
- <mkdir dir="${tmp}"/>
- <copy todir="${tmp}/less">
- <fileset dir="${bootstrap}/less"/>
- </copy>
- <delete file="${tmp}/less/variables.less"/>
- <delete file="${tmp}/less/bootstrap.less"/>
- <copy file="${themes}/groupofthings/frontend/less/variables.less" todir="${tmp}/less"/>
- <copy file="${themes}/groupofthings/frontend/less/bootstrap.less" todir="${tmp}/less"/>
- <copy file="${themes}/groupofthings/frontend/less/site.less" todir="${tmp}/less"/>
- <copy file="${themes}/groupofthings/frontend/less/bootswatch.less" todir="${tmp}/less"/>
- <exec executable="${lessc}" >
- <arg value="--compress"/>
- <arg value="${tmp}/less/bootstrap.less"/>
- <arg value="${themes}/groupofthings/frontend/css/bootstrap.css"/>
- </exec>
- <!--
- <exec executable="${lessc}" >
- <arg value="-x"/>
- <arg value="${tmp}/less/responsive.less"/>
- <arg value="${themes}/groupofthings/frontend/css/bootstrap-responsive.css"/>
- </exec>
- -->
- <delete dir="${tmp}"/>
- </target>
- <!-- TARGET: crudify -Dtable=table_name -->
- <!-- Runs to rivety crudifier against a table name. Uses project crudify templates, places results in project. -->
- <target name="crudify">
- <echo message="Running crudify on ${table}" />
- <exec executable="php" >
- <arg value="${local_deploy}/core/default/bin/crudify.php"/>
- <arg value="${table}"/>
- <arg value="0"/>
- <arg value="0"/>
- <arg value="${basedir}/crudify_templates"/>
- <arg value="${basedir}"/>
- </exec>
- </target>
- <!-- TARGET: hose -Dtable=table_name -->
- <!-- Removes code generated by crudify. Use with care. -->
- <target name="hose">
- <echo message="removing crudified code for ${table}" />
- <!-- Javascript in an ant file. Hoo boy. -->
- <script language="javascript"> <![CDATA[
- function ucFirst(string) {
- return string.substring(0, 1).toUpperCase() + string.substring(1).toLowerCase();
- }
- function setProperty(key,value){
- prop = project.createTask("property");
- prop.setName(key);
- prop.setValue(value);
- prop.perform();
- }
- tableName = project.getProperty("table");
- moduleName = tableName.substring(0,tableName.indexOf("_"));
- objectName = tableName.substring(tableName.lastIndexOf("_") + 1);
- tableObjectName = ucFirst(moduleName)
- + ucFirst(objectName)
- + ".php";
- controllerName = ucFirst(objectName) + "Controller.php";
- basedir = project.getProperty("basedir");
- themePath = basedir + "/modules/" + moduleName + "/views/frontend/tpl_controllers/" + objectName;
- jsPath = basedir + "/modules/" + moduleName + "/views/frontend/js";
- jsPattern = moduleName + "-" + objectName + "-*.js";
- controllerPath = basedir + "/modules/" + moduleName + "/controllers/" + controllerName;
- modelPath = basedir + "/modules/" + moduleName + "/models/" + tableObjectName;
- println("Theme files: " + themePath);
- println("Controller: " + controllerPath);
- println("Model Object: " + modelPath);
- setProperty("theme_dir",themePath);
- setProperty("js_path",jsPath);
- setProperty("js_pattern",jsPattern);
- setProperty("model_class",modelPath);
- setProperty("controller_class",controllerPath);
- ]]> </script>
- <delete dir="${theme_dir}"/>
- <delete file="${model_class}"/>
- <delete file="${controller_class}"/>
- <echo message="${js_path}"/>
- <echo message="${js_pattern}"/>
- <delete dir="${js_path}">
- <include name="${js_pattern}"/>
- </delete>
- </target>
- <!-- TARGET: message -->
- <!-- displays a help message with available targets -->
- <target name="message">
- <echo message="Available targets are 'local','deploy','test','lessc'"/>
- <echo message="local: do a rivety build, copy config files in, deploy locally and then symlink the modules and themes folders"/>
- <echo message="deploy: This script will only build, copy and symlink, it doesn't actually deploy."/>
- </target>
- <target name="recrudify" depends="hose,crudify">
- </target>
- </project>
Add Comment
Please, Sign In to add comment