[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ant-user
Subject:    RE: Un"bat"ing development: how to realize a forked ant
From:       "Stefan Schulz" <schulz () ivs ! tu-berlin ! de>
Date:       2003-02-28 9:51:50
[Download RAW message or body]

Hi,

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.

Regards
Stefan


<target name="buildproject" description="Executes ant with a redefined
environment.">
  <!-- 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"/>
    </fileset>
  </path>
  <property name="project.java.home" location="java"/>
  <path id="project.java.path">
    <fileset dir="${project.java.home}">
      <include name="lib/*.jar"/>
    </fileset>
  </path>
  <property name="project.thirdparty.home" location="thirdparty"/>
  <path id="project.thirdparty.path">
    <fileset dir="${project.thirdparty.home}">
      <include name="**/*.jar"/>
    </fileset>
  </path>
  <!-- construct the class path to use -->
  <path id="local.class.path">
    <path refid="project.java.path"/>
    <path refid="project.ant.path"/>
    <path refid="project.thirdparty.path"/>
  </path> 
  <!-- Execute ant on the property build file -->
  <java classname="org.apache.tools.ant.Main"
        failonerror="yes"
        fork="yes"
        maxmemory="128m"
        dir="develop">
    <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}"/>
  </java>
</target>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic