ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject AW: calculating relative paths
Date Wed, 09 Sep 2009 11:31:06 GMT
I added that in rev812881.
So it should be available with Ant 1.8.0 this year.


  <!-- Ensure we have platform dependent path separator -->
  <property name="base" location="${basedir}"/>
  <!-- an existing file as anchor for calculating paths -->
  <property name="testfile" value="condition${file.separator}antversion-test.xml"/>

  <target name="testLocation">
    <property name="foo" location="${testfile}"/>
    <au:assertPropertyEquals name="foo" value="${base}${file.separator}${testfile}"/>
  <target name="testLocationWithRecursive">
    <property name="foo" location="${testfile}" relative="false"/>
    <au:assertPropertyEquals name="foo" value="${base}${file.separator}${testfile}"/>

  <target name="testRelative">
    <property name="foo" location="${testfile}" relative="true"/>
    <au:assertPropertyEquals name="foo" value="${testfile}"/>

  <target name="testRelativeBase">
    <property name="foo" location="${testfile}" relative="true" basedir="${base}"/>
    <au:assertPropertyEquals name="foo" value="${testfile}"/>
  <target name="testRelativeUnderBase">
    <property name="foo" location="${testfile}" relative="true" basedir="condition"/>
    <au:assertPropertyEquals name="foo" value="antversion-test.xml"/>

  <target name="testRelativeUnderBase2">
    <property name="foo" location="${testfile}" relative="true" basedir="cvs"/>
    <au:assertPropertyEquals name="foo" value="..${file.separator}condition${file.separator}antversion-test.xml"/>

  <target name="testRelativeOverBase">
    <property name="foo" location="${testfile}" relative="true" basedir=".."/>
    <au:assertPropertyEquals name="foo" value="taskdefs${file.separator}${testfile}"/>

>-----Urspr√ľngliche Nachricht-----
>Von: [] 
>Gesendet: Mittwoch, 9. September 2009 11:30
>Betreff: AW: calculating relative paths
>>Perhaps I should raise an enhancement request.  A couple of new
>>attributes "relative" (default false) and "basedir" (default
>>${basedir}) that can be used in conjunction with the "location"
>>attribute seem a relatively minor addition, and would reduce my
>>problem to <property name="relpath" location="${src.dir}"
>>relative="true" basedir="${build.dir}/xsltdoc"/>
>>Any of the developers care to comment?
>The enhancement of <property location/> seems to be good candidate.
><property value="my/file.txt"/>
>-->  my/file.txt
><property location="my/file.txt"/>
>--> path/to/projectbasedir/my/file.txt
><property location="my/file.txt" relative="true"/>
>--> my/file.txt
><property location="my/file.txt" relative="true" basedir="my"/>
>--> file.txt
><property location="my/file.txt" relative="true" basedir="my/dir"/>
>--> ../my/file.txt
><property location="my/file.txt" relative="true" basedir=".."/>
>--> projectbasedir/my/file.txt
>To unsubscribe, e-mail:
>For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message