Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Wordpress Apache ANT script
<?xml version="1.0" encoding="UTF-8"?>
<project basedir=".">
<property name="mysql" value="c:\Program Files\wamp\bin\mysql\mysql5.5.8\bin\" description="path to Mysql"/>
<property name="yuicompressor" value="c:\Program Files\yuicompressor-2.4.2\build\yuicompressor-2.4.2.jar" description="Path to yuicompressor-2.4.2.jar"/>
<property name="database" value="wp" description="Local database name"/>
<property name="url.production" value="http://www.blogs.com/wp" description="Production URL" />
<property name="url.local" value="http://localhost/blog" description="Local url" />
<property name="wp.template" value="twentyten" description="Default Wordpress template" />
<property name="om.template" value="omdesign" description="New Wordpress template" />
<target name="backup.database">
<mkdir dir="backup" />
<delete failonerror="false">
<fileset file="wp-content/plugins/*.sql" />
</delete>
<get dest="build/clean.sql " src="http://wp.omdesign.cz/cdn/clean.sql" />
<!-- run clean script from private CDN -->
<exec dir="" executable="${mysql}mysql"
output="backup/output.sql">
<arg line="--host=localhost" />
<arg line="-u root" />
<arg line="--password=" />
<arg line="--execute='source ./build/clean.sql'" />
<arg line="${database}" />
</exec>
<!-- make database dump -->
<exec dir="" executable="${mysql}mysqldump"
output="backup/${database}_local.sql">
<arg line="--host=localhost" />
<arg line="-u root" />
<arg line="--password=" />
<arg line="--add-drop-table" />
<arg line="--default-character-set=utf8" />
<arg line="--complete-insert" />
<arg line="${database}" />
</exec>
<!-- process server SQL -->
<copy file="backup/${database}_local.sql" tofile="backup/${database}_server.sql" encoding="utf-8">
<filterchain>
<replacestring from="${url.local}" to="${url.production}"/>
</filterchain>
</copy>
</target>
<!-- minify css -->
<target name="minify.js" description="Minifi all js files">
<mkdir dir="build/wp-content/themes/${om.template}/js" />
<apply executable="java" parallel="false" verbose="true" failonerror="true" dest="build/wp-content/themes/omdesign/js">
<fileset dir="wp-content/themes/${om.template}/js">
<include name="*.js" />
</fileset>
<arg line="-jar"/>
<arg path="${yuicompressor}"/>
<srcfile/>
<arg value="--charset" />
<arg value="UTF-8" />
<arg line="-o"/>
<mapper type="glob" from="*.js" to="*.js"/>
<targetfile/>
</apply>
</target>
<target name="minify.css" description="Minifi all CSS files">
<mkdir dir="build/wp-content/themes/${om.template}" />
<apply executable="java" parallel="false" verbose="true" failonerror="true" dest="build/wp-content/themes/omdesign">
<fileset dir="wp-content/themes/${om.template}">
<include name="*.css" />
</fileset>
<arg line="-jar"/>
<arg path="${yuicompressor}"/>
<arg line="--line-break 0"/>
<srcfile/>
<arg line="-o"/>
<mapper type="glob" from="*.css" to="*.css"/>
<targetfile/>
</apply>
</target>
<target name="basic.setup" description="Basic Wordpress setup">
<get src="http://wp.omdesign.cz/cdn/robots.txt" dest="robots.php" />
<get src="http://downloads.sourceforge.net/adminer/adminer-3.1.0-cs.php" dest="adminer.php" />
<antcall target="core.plugins" />
<antcall target="core.template" />
</target>
<target name="build.wordpress" description="Generate WP install file">
<delete includeEmptyDirs="true" failonerror="false">
<fileset dir="build"/>
</delete>
<mkdir dir="build" />
<copydir dest="build/wp-content" src="wp-content" />
<delete includeEmptyDirs="true">
<fileset dir="build/wp-content/themes/${om.template}/js"/>
<fileset file="build/wp-content/themes/${om.template}/style.css"/>
</delete>
<antcall target="minify.css" />
<antcall target="minify.js" />
<zip destfile="install.zip">
<zipfileset dir="wp-admin" prefix="wp-admin" />
<zipfileset dir="wp-includes" prefix="wp-includes" />
<zipfileset dir="build/wp-content" prefix="wp-content" />
<zipfileset dir="." includes="*.php" />
<zipfileset dir="." includes="readme.html" />
<zipfileset dir="." includes="license.txt" />
</zip>
<delete includeEmptyDirs="true" failonerror="false">
<fileset dir="build" />
</delete>
</target>
<target name="core.template" description="Generate new empty core template">
<delete includeEmptyDirs="true" failonerror="false">
<fileset dir="wp-content/themes/${om.template}"/>
</delete>
<mkdir dir="wp-content/themes/${om.template}" />
<copy todir="wp-content/themes/${om.template}">
<fileset dir="wp-content/themes/${wp.template}">
<exclude name="**/*.php" />
<exclude name="**/images/**" />
</fileset>
</copy>
<!-- copy php -->
<copy todir="wp-content/themes/${om.template}" encoding="utf-8">
<fileset dir="wp-content/themes/${wp.template}">
<include name="**/*.php"/>
</fileset>
<filterchain>
<!-- remove PHP comments -->
<replaceregex pattern="/\*.*?\*/" flags="gims" byline="false" />
<!-- remove HTML comments -->
<replaceregex pattern="&lt;!--[^>]*-->" flags="gims" byline="false" />
<!-- replace twentyten to om -->
<replaceregex pattern="${wp.template}" replace="${om.template}" flags="gi" />
<!-- remove empty spaces before PHP start -->
<replaceregex pattern="&lt;\?php\s+" replace="&lt;\?php " flags="gim" byline="false" />
<replaceregex pattern="&lt;\?php\s+\?>" flags="gim" byline="false" />
</filterchain>
</copy>
<delete file="wp-content/themes/${om.template}/onecolumn-page.php" />
<delete file="wp-content/themes/${om.template}/sidebar-footer.php" />
<delete file="wp-content/themes/${om.template}/comments.php" />
<delete file="wp-content/themes/${om.template}/attachment" />
<mkdir dir="wp-content/themes/${om.template}/js" />
<mkdir dir="wp-content/themes/${om.template}/images" />
<!-- fileset for replacement -->
<fileset dir="wp-content/themes/${om.template}" includes="**/*.php" id="php.fileset" />
<fileset dir="wp-content/themes/${om.template}" includes="**/function.php" id="php.function"/>
<get dest="wp-content/themes/${om.template}/js">
<url url="http://www.appelsiini.net/download/jquery.lazyload.mini.js" />
<url url="http://html5shim.googlecode.com/svn/trunk/html5.js" />
</get>
<get dest="wp-content/themes/${om.template}/screenshot.png" src="http://wp.omdesign.cz/cdn/screenshot.png" />
<get dest="wp-content/themes/${om.template}/style.css" src="http://wp.omdesign.cz/cdn/style.css" />
<get dest="wp-content/themes/${om.template}/js/main.js" src="http://wp.omdesign.cz/cdn/main.js" />
</target>
<target name="core.plugins" description="Download core Wordpress plugins">
<delete includeEmptyDirs="true" failonerror="false">
<fileset dir="wp-content/plugins/akismet" />
<fileset file="wp-content/plugins/hello.php" />
</delete>
<get dest="wp-content/plugins">
<url url="http://downloads.wordpress.org/plugin/wordpress-seo.zip" />
<url url="http://downloads.wordpress.org/plugin/mce-table-buttons.1.0.3.zip" />
<url url="http://downloads.wordpress.org/plugin/multiple-galleries.0.3.zip" />
</get>
<unzip dest="wp-content/plugins">
<fileset dir="wp-content/plugins" includes="**/*.zip" />
</unzip>
<delete failonerror="false">
<fileset file="wp-content/plugins/*.zip" />
</delete>
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.