ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Schulz" <>
Subject RE: Un"bat"ing development: how to realize a forked ant
Date Fri, 28 Feb 2003 09:51:50 GMT

this seems to be another good approach.

I now made ant to execute ant by the application of the java task. That
is, I have an extra build.xml (could also be a target in the project's
build.xml) that sets up the environment and calls a "local" ant. What I
learned from past projects is, that having 10 developers results in
different tool versions installed for each of them. That is ant, java,
and others. Hence, my project always includes the tool versions it
relies on. So, ant and at least the jre are local. I don't think the
multiplication of this tools' files by each project matters at nowadays
storage prices. The meta-build file will call the local ant, so the
versions of ant and needed extension or java libraries are guaranteed.

The major problem I had with starting ant was, that ant did not care
about setting JAVA_HOME. Including the java path directly finally helped
to find the required jdk libraries. The alternative would be to use the
<exec>-task, as described by Dominique.

My target looks somewhat like appended below. Maybe it is of use to
anyone or someone has a smarter idea.


<target name="buildproject" description="Executes ant with a redefined
  <!-- Define custom environment variables -->
  <dirname property="project.home" file="${ant.file}"/>
  <!-- Define the local homes and paths -->
  <property name="project.ant.home" location="ant"/>
  <path id="project.ant.path">
    <fileset dir="${project.ant.home}">
      <include name="lib/*.jar"/>
  <property name="" location="java"/>
  <path id="">
    <fileset dir="${}">
      <include name="lib/*.jar"/>
  <property name="project.thirdparty.home" location="thirdparty"/>
  <path id="project.thirdparty.path">
    <fileset dir="${project.thirdparty.home}">
      <include name="**/*.jar"/>
  <!-- construct the class path to use -->
  <path id="local.class.path">
    <path refid=""/>
    <path refid="project.ant.path"/>
    <path refid="project.thirdparty.path"/>
  <!-- Execute ant on the property build file -->
  <java classname=""
    <classpath refid="local.class.path"/>
    <jvmarg value="-Dant.home=${project.ant.home}"/>
    <jvmarg value="-Dbasedir=${project.home}"/>
    <jvmarg value="-DCUSTOM_ENV_VAR=${custom.env.var}"/>
    <arg line="${ant.arguments}"/>

View raw message