tags:

views:

17

answers:

1

In ant, I need to create a file named "current_build" with the only content (in plaintext) being the full name of the directory:

So I have this:

    <echo file="${trainer.dir}/current_build">${trainer.dir}</echo>

And in my build.properties, I have a relative path set:

        trainer.dir=../trainer

In the current_build file, I would like it to be the whole path... like: c:\workspace\project\trainer

How can I do this? Right now, it just prints ../trainer to the file

+1  A: 

Set a property using the location attribute of the property element/task: this will expand the value (if it's relative) to a full path relative to basedir specified in the top-level project element:

<project name="test" basedir="." default="test">
  <property name="trainer.dir" location="foo"/>
  <target name="test">
    <mkdir dir="${trainer.dir}"/>
    <echo file="${trainer.dir}/current_build">${trainer.dir}</echo>
  </target>
</project>

If the value is coming from a build properties file, use another property to capture its full path name:

<project name="test" basedir="." default="test">
  <property file="build.properties"/>
  <property name="trainer.fulldir" location="${trainer.dir}"/>
  <target name="test">
    <mkdir dir="${trainer.fulldir}"/>
    <echo file="${trainer.fulldir}/current_build">${trainer.fulldir}</echo>
  </target>
</project>
Richard Cook
This property is coming from a build.properties file.. Like this <property file="build.properties" />
Grasper
See addition to answer.
Richard Cook