build/build-shared.xml
<?xml version="1.0" encoding="utf-8"?>
<project>
<property file="${shared.dir}/build/shared.properties"/>
<exec executable="hostname" outputproperty="computer.hostname"/>
<condition property="not.on.teamcity">
<not>
<contains string="${computer.hostname}" substring="teamcity"/>
</not>
</condition>
<path id="yuicompressor.classpath">
<fileset dir="${ant.lib}">
<include name="${yuicompressor.jar}"/>
<include name="${yuiant.jar}"/>
</fileset>
</path>
<taskdef name="yuicompress" classname="com.yahoo.platform.yui.compressor.YUICompressTask">
<classpath>
<path refid="yuicompressor.classpath"/>
</classpath>
</taskdef>
<path id="liquibasetasks.classpath">
<fileset dir="${ant.lib}">
<include name="${liquibase.jar}"/>
<include name="${mysqlDriver.jar}"/>
</fileset>
</path>
<taskdef resource="liquibasetasks.properties">
<classpath refid="liquibasetasks.classpath"/>
</taskdef>
<path id="groovy.classpath">
<fileset dir="${ant.lib}">
<include name="${groovy.jar}"/>
<include name="${snakeyaml.jar}"/>
</fileset>
</path>
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy">
<classpath refid="groovy.classpath"/>
</taskdef>
<target name="gates">
<antcall target="checkstyle"/>
<antcall target="test"/>
<antcall target="messDetect"/>
</target>
<target name="checkstyle">
<antcall target="phpcs"/>
</target>
<target name="test">
<antcall target="phpUnit"/>
<antcall target="behat"/>
</target>
<target name="messDetect" description="Mess Detection">
<antcall target="phpcpd"/>
</target>
<target name="phpUnit" description="PHPUnit Test Runner">
<mkdir dir="${build.logs}"/>
<exec dir="${tests.dir}" executable="phpunit" failonerror="true">
<arg line=" --log-junit ${build.logs}/phpunit.xml
--coverage-clover ${build.logs}/clover.xml
--coverage-html ${build.dir}/coverage
--configuration ${site.dir}/config/phpunit.xml
php"/>
</exec>
</target>
<target name="behat">
<mkdir dir="${build.logs}/behat"/>
<exec dir="${site.dir}/test/php/acceptance"
executable="php"
failonerror='true'>
<arg line="${site.dir}/vendor/bin/behat -f junit,pretty --tags ~@wip --ansi --out ${build.logs}/behat,"/>
</exec>
</target>
<target name="phpcs" description="PHP Code Sniffer">
<mkdir dir="${build.logs}"/>
<exec executable="phpcs">
<arg line="--version"/>
</exec>
<exec dir="${src.dir}"
executable="phpcs"
failonerror="true">
<arg line="-s"/>
<arg line="--standard=${shared.dir}/build/codingStandard.xml"/>
<arg line="--report-checkstyle=${build.logs}/checkstyle.xml ."/>
<arg line="--report-full"/>
</exec>
</target>
<target name="phpcs-legacy" description="PHP Code Sniffer">
<mkdir dir="${build.logs}"/>
<exec executable="phpcs">
<arg line="--version"/>
</exec>
<exec dir="${src.dir}/../"
executable="phpcs"
failonerror="true">
<arg line="-s"/>
<arg line="--standard=${shared.dir}/build/codingStandard.xml"/>
<arg line="--ignore=*/coverage/*,vendor/*,node_modules/*,components/*,doc_root/resources/*"/>
<arg line="--report-checkstyle=${build.logs}/checkstyle-legacy.xml ."/>
<arg line="--report-full"/>
</exec>
</target>
<target name="phpcpd" description="PHP Copy/Paste Detector">
<exec dir="${src.dir}"
executable="phpcpd"
failonerror="true">
<arg line="--log-pmd ${build.logs}/pmd-cpd.xml ."/>
</exec>
</target>
<target name="sshFromMac">
<property name="keyfile" value="${mac.keyfile}"/>
<property file="/Users/travi/properties.properties"/>
</target>
<target name="sshFromLinux">
<property name="keyfile" value="${linux.keyfile}"/>
<property file="/home/travi/properties.properties"/>
</target>
<target name="toQA">
<property name="server.host" value="${qa.server.host}"/>
<property name="database.url" value="${qa.database.url}"/>
<property name="database.username" value="${qa.database.username}"/>
<property name="database.password" value="${qa.database.password}"/>
</target>
<target name="toProduction">
<property name="server.host" value="${prod.server.host}"/>
<property name="database.url" value="${prod.database.url}"/>
<property name="database.username" value="${prod.database.username}"/>
<property name="database.password" value="${prod.database.password}"/>
</target>
<target name="toLocal">
<property name="database.url" value="${local.database.url}"/>
<property name="database.username" value="${local.database.username}"/>
<property name="database.password" value="${local.database.password}"/>
</target>
<target name="deploy" depends="dist">
<scp
file="${deploy.archive}"
todir="${server.username}@${server.host}:${server.path}"
trust="true"
verbose="true"
preserveLastmodified="true"
keyfile="${keyfile}"
passphrase="${passphrase}"
/>
<sshexec
host="${server.host}"
username="${server.username}"
keyfile="${keyfile}"
passphrase="${passphrase}"
trust="true"
commandResource="${pathToDeployScript}deploy.txt"
/>
</target>
<target name="dist" depends="build">
<antcall target="dist.tar"/>
</target>
<target name="build" depends="clean,createBuildDirs">
<exec dir="${site.dir}" executable="grunt" failonerror='true'>
<arg line="compile"/>
</exec>
<copy todir="${building.dir}" preservelastmodified="true">
<fileset refid="to.deploy"/>
</copy>
</target>
<target name="createBuildDirs">
<mkdir dir="${building.dir}"/>
</target>
<target name="createDistDirs">
<mkdir dir="${dist.dir}"/>
</target>
<target name="dist.tar">
<tar
destfile="${deploy.archive}"
basedir="${building.dir}"
compression="bzip2"
excludes="vendor/travi/framework/npm_modules/**"
longfile="gnu"
/>
</target>
<macrodef name="update-site-database">
<attribute name="database"/>
<attribute name="changeLogFile"/>
<sequential>
<updateDatabase
changeLogFile="@{changeLogFile}"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://${database.url}:3306/@{database}"
username="${database.username}"
password="${database.password}"
promptOnNonLocalDatabase="${prompt.user.if.not.local.database}"
dropFirst="false"
classpathref="liquibasetasks.classpath"
/>
</sequential>
</macrodef>
<target name="concat-defaults">
<groovy>
println "new hello world"
import org.yaml.snakeyaml.Yaml
def file = new File("${properties['site.dir']}/config/pageDependencies.yml")
def yaml = new Yaml()
def parsed = yaml.load(file.getText())
println parsed.site
</groovy>
</target>
<target name="clean">
<delete dir="${build.logs}"/>
<delete dir="${build.dir}/coverage"/>
<delete dir="${build.dir}/site"/>
<delete dir="${build.dir}/dist"/>
<exec dir="${site.dir}" executable="grunt" failonerror='true'>
<arg line="clean"/>
</exec>
</target>
</project>