Skip to content

Instantly share code, notes, and snippets.

@nishigori
Created June 30, 2012 08:42
Show Gist options
  • Save nishigori/3022992 to your computer and use it in GitHub Desktop.
Save nishigori/3022992 to your computer and use it in GitHub Desktop.
build.xml for Symfony2.1
<?xml version="1.0" encoding="UTF-8"?>
<project name="symfony" default="main">
<property name="appdir" value="${basedir}/app" />
<available file="${basedir}/php-cs-fixer.phar" property="php-cs-fixer-exist" />
<available file="${basedir}/composer.phar" property="composer-exist" />
<target name="main"
description="Run almost task"
depends="lint,vendor-install,migrate,phpunit"
/>
<target name="build-init"
description="Initialize build environment"
depends="vendor-install, symfony-configure, get-php-cs-fixer" />
<target name="symfony-configure">
<exec executable="bash" failonerror="true">
<arg value="-c" />
<!--<arg value="sudo setfacl -R -m u:www-data:rwx -m -m u:`whoami`:rwx ${basedir}/app/cache ${basedir}/app/logs;" />-->
<!--<arg value="sudo setfacl -dR -m u:www-data:rwx -m -m u:`whoami`:rwx ${basedir}/app/cache ${basedir}/app/logs;" />-->
<arg value='sudo chmod +a "_www allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs;' />
<arg value='sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs;' />
</exec>
<touch file="${basedir}/app/config/parameters.yml" />
<!--<copy file="{$basedir}/app/config/parameters.ini.dist" tofile="${basedir}/app/config/parameters.yml" />-->
<exec executable="php" failonerror="true">
<arg line="${basedir}/app/check.php" />
</exec>
<exec executable="php" failonerror="true">
<arg line="${basedir}/app/console assets:install web --symlink" />
</exec>
</target>
<target name="vendor-install" depends="get-composer" >
<exec executable="php" failonerror="true">
<arg line="composer.phar install --prefer-source" />
</exec>
</target>
<target name="get-composer" unless="composer-exist">
<exec executable="bash" failonerror="true">
<arg value="-c" />
<arg value="curl -s http://getcomposer.org/installer | php" />
</exec>
</target>
<target name="lint"
description="Perform syntax check of sourcecode files">
<apply executable="php" failonerror="true">
<arg value="-l" />
<fileset dir="${basedir}/app">
<include name="**/bootstrap.php*" />
<include name="**/autoload.php" />
<include name="**/AppKernel.php" />
<include name="**/AppCache.php" />
</fileset>
<fileset dir="${basedir}/src">
<include name="**/*.php" />
</fileset>
</apply>
</target>
<target name="migrate">
<exec executable="bash" failonerror="true">
<arg value="-c" />
<arg value="echo 'yes' | ${basedir}/app/console doctrine:migrations:migrate" />
</exec>
</target>
<target name="phpunit"
description="Run unit tests with PHPUnit">
<!--<clean.log file="junit.xml" />-->
<exec dir="${basedir}" executable="phpunit">
<arg value="--configuration" />
<arg path="${basedir}/app" />
</exec>
</target>
<target name="get-php-cs-fixer" unless="php-cs-fixer-exist">
<exec executable="bash">
<arg value="-c" />
<arg value="curl -O http://cs.sensiolabs.org/get/php-cs-fixer.phar" />
</exec>
</target>
<target name="deploy-to-stage">
<deploy env="stage" />
</target>
<macrodef name="deploy">
<attribute name="env" />
<sequential>
<exec executable="bash" failonerror="true">
<arg value="-c" />
<arg value="cap @{env} deploy:update" />
</exec>
<exec executable="bash" failonerror="true">
<arg value="-c" />
<arg value="echo 'yes' | cap @{env} symfony:doctrine:migrations:migrate" />
</exec>
</sequential>
</macrodef>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment