Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Apache Ant tagets for Composer commands.
<?xml version="1.0" encoding="UTF-8"?>
<project name="Composer Targets" default="build">
<property name="builddir" value="${basedir}/build"/>
<property name="composer" value="${builddir}/composer.phar"/>
<target name="php-check">
<condition property="php" value="php">
<isset property="${php}"/>
<target name="prepare">
<mkdir dir="${builddir}" />
<target name="composer-check" depends="prepare">
<available file="${composer}" property="composer.present"/>
<target name="composer-download" depends="composer-check" unless="composer.present">
<property name="composer.noselfupdate" value="true"/>
<get src="" dest="${composer}"/>
<target name="composer-selfupdate" depends="php-check,composer-download" unless="composer.noselfupdate">
<exec executable="${php}">
<arg value="${composer}"/>
<arg value="self-update"/>
<arg value="--quiet"/>
<target name="composer" depends="composer-selfupdate" unless="composer.noupdate" description="Run composer update">
<exec executable="${php}">
<arg value="${composer}"/>
<arg value="update"/>
Copy link

bezborodow commented Jul 16, 2015

<exec ... failonerror="true"> may be useful to fail the entire build if Composer fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment