ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Jan.Mate...@rzf.fin-nrw.de>
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.

Jan

  <!-- 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>
  
  <target name="testLocationWithRecursive">
    <property name="foo" location="${testfile}" relative="false"/>
    <au:assertPropertyEquals name="foo" value="${base}${file.separator}${testfile}"/>
  </target>

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

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

  <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>

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

>-----Urspr√ľngliche Nachricht-----
>Von: Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de] 
>Gesendet: Mittwoch, 9. September 2009 11:30
>An: user@ant.apache.org
>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
>
>
>Jan
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>

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


Mime
View raw message