Erlang & Ant

François-Denis Gonthier neumann@REDACTED
Mon May 17 19:11:32 CEST 2004


Yesterday, I've worked hard to get Ant to compile a little Erlang project.
It's only the second buildfile I've ever written so I might have missed some
stuff.

I've decided to use a more standard way of building my projects (Emakefile)
but I think it's a waste to simply erase what took me hours of a perfectly
good Sunday night so I decided to send it to this mailing list, in hope that
interested people will find it.

<?xml version="1.0"?>
<project name="ErlangIRC" default="compile" basedir=".">

  <taskdef resource="net/sf/antcontrib/antcontrib.properties">
    <classpath>
      <pathelement location=".\lib\ant-contrib-1.0b1.jar"/>
    </classpath>
  </taskdef>

  <property name="outdir" value="ebin" />
  <property name="srcdir" value="src" />

  <property name="erlang.compiler" value="c:\Devel\Erlang\bin\erlc.exe" />
  <property name="erlang.runtime" value="c:\Devel\Erlang\bin\erl.exe" /> 

  <fileset id="srcfiles" dir="src" includes="*.erl" /> 
  <fileset id="outfiles" dir="ebin" includes="*.beam" />

  <target name="compile">
    <foreach target="erlang-compile" param="erlang.file">
      <path>
	<fileset refid="srcfiles" />
      </path>
    </foreach>
  </target> 

  <target name="erlang-compile">
    <uptodate srcfile="${erlang.file}" property="dont.build">
      <mapper type="regexp" 
	from="^(.*)\\${srcdir}\\(.*).erl$$" 
	to="\1\\${outdir}\\\2.beam" />
    </uptodate>
   
    <if><not><istrue value="${dont.build}" /></not>
      <then>
	<exec executable="${erlang.compiler}" dir=".">
	  <arg value="+debug_info" />
	  <arg value="-W" />
	  <arg value="-oebin" />
	  <arg value="${erlang.file}" />
	</exec>
      </then>      
    </if>
  </target>
</project>



More information about the erlang-questions mailing list