Simple Ant build file to build and run cpp files

I’ve tried to look for a simple ant build file for compiling c++ files however I’ve had no joy. After couple of hours or so I’ve made my own. It is basic for now however I’m going to update it later. Anyhoo, here it is if you are interested.

<project name="builder" default="build" basedir=".">

	<taskdef resource="net/sf/antcontrib/"/>

	<property name="src.dir" value="src"/>
	<property name="build.dir" value="bin"/>
	<property name="etc.dir" value="etc"/>
	<property name="resultset" value=""/>

	<target name="init">
		<mkdir dir="${build.dir}"/>
		<mkdir dir="${src.dir}"/>
		<mkdir dir="${etc.dir}"/>
	<target name="build" depends="init">  
		<delete file="main"/>
		<foreach param="" target="">
				<fileset dir="${src.dir}" includes="*.cpp"/>  

	<target name="">
		<propertyregex override="yes"
			property="filename" input="${}"
			regexp=".*/(.*).cpp" replace="\1"/>
		<delete file="${build.dir}/${filename}.o"/>
		<echo message="building ${filename}.cpp"/>
		<exec executable="g++">
			<arg value="-Wall"/>
			<arg value="-c"/>
			<arg value="${src.dir}/${filename}.cpp"/>
			<arg value="-o"/>
			<arg value="${build.dir}/${filename}.o"/>

	<target name="make">
		<delete file="${etc.dir}/"/>
		<echo file="${etc.dir}/" append="true" message="path="/> 
		<foreach param="param.make" target="do.make">
				<fileset dir="${build.dir}" includes="*.o"/>  

	<target name="do.make">
		<propertyregex override="yes"
				property="filename" input="${param.make}"
				regexp=".*/(.*).o" replace="\1"/>
		<echo file="${etc.dir}/" append="true" message="${build.dir}/${filename}.o "/> 

	<target name="run" depends="make">
		<property prefix="make" file="${etc.dir}/"/>
		<echo message="${make.path}"/>
		<exec command="g++ ${make.path} -o main"/>
		<exec executable="./main"/>