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: How to conditionally add something to a path ?
Date Mon, 19 Dec 2005 13:28:00 GMT
psst - little secret: a look into Ant´s buildfile will show some secrets ;-)

Jan 

>-----Ursprüngliche Nachricht-----
>Von: Com Pegasus-CC-Hotline 
>[mailto:pegasus-cc-hotline.com@siemens.com] 
>Gesendet: Montag, 19. Dezember 2005 14:08
>An: Ant Users List
>Betreff: AW: How to conditionally add something to a path ?
>
>Hi Jan,
>
>wunderbar, your example works! (And I managed to adapt it to 
>my build file.)
>
>Thank you very much, I was really close to giving up!  :-)
>
>cu,
> Thomas
>
>
>-----Ursprüngliche Nachricht-----
>Von: Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de]
>Gesendet: Montag, 19. Dezember 2005 12:48
>An: user@ant.apache.org
>Betreff: AW: How to conditionally add something to a path ?
>
>
>Try selectors.
>
>Example:
>- create two files (echo . > lib1.txt) 
>  lib1.txt    : symbol for a library
>  lib1b.txt   : symbol for a library depending on lib1
>- copy the code provided into a build.xml
>
>- run ant
>  Buildfile: build.xml
>     [echo] Path:
>     [echo] - C:\TEMP\ant-conditionalSelector\build.xml
>     [echo] - C:\TEMP\ant-conditionalSelector\lib1.txt
>     [echo] - C:\TEMP\ant-conditionalSelector\lib1b.txt
>  
>- rename lib1.txt into lib1.txt.old
>- rerun ant
>  Buildfile: build.xml
>     [echo] Path:
>     [echo] - C:\TEMP\ant-conditionalSelector\build.xml
>
> 
>Jan
>
>
>---8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------
>8-<-------8-<----
><project>
>
>    <!-- check if the 'base' file is there -->
>    <available property="lib1.present" file="lib1.txt"/>
>
>    <!-- all files which depend on 'base' -->
>    <selector id="needs.lib1">
>        <or>
>            <filename name="lib1*.txt"/>
>        </or>
>    </selector>
>
>    <!-- files without any dependency -->
>    <selector id="needs.nothing">
>        <or>
>            <filename name="build.xml"/>
>        </or>
>    </selector>
>
>    <!-- the path with all 'valid' files -->
>    <path id="p">
>        <fileset dir=".">
>            <or>
>                <selector refid="needs.lib1" if="lib1.present"/>
>                <selector refid="needs.nothing"/> 
>            </or>
>        </fileset>
>    </path>
>
>    <!-- print the result -->
>    <pathconvert property="p.value" refid="p" 
>pathsep="${line.separator}- " />
>    <echo>Path:${line.separator}- ${p.value}</echo>
></project>
>---8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------
>8-<-------8-<----
>
>
>
>>-----Ursprüngliche Nachricht-----
>>Von: Com Pegasus-CC-Hotline 
>>[mailto:pegasus-cc-hotline.com@siemens.com] 
>>Gesendet: Montag, 19. Dezember 2005 11:56
>>An: user@ant.apache.org
>>Betreff: How to conditionally add something to a path ?
>>
>>Hello,
>>
>>I am trying to add an entry to a path, if some other entry is 
>>not existant. I'm trying since hours now,=20 without success. 
>>I am somewhere here:
>>
>>
>>	<available file=3D"${jarpath}/**/jacorb*.jar"
>>property=3D"jacorb.present"/>
>>
>>	<path id=3D"classpath">
>>		<fileset dir=3D"${jarpath}">
>>		   <include name=3D"**/*.jar" />
>>		   <exclude name=3D"orbacus.jar" />
>>		</fileset>
>>		<if>
>>		   <isfalse property=3D"${jacorb.present}" />
>>		   <fileset dir=3D"${jarpath}">
>>		      <include name=3D"orbacus.jar" />
>>		   </fileset>
>>		</if>
>>	</path>
>>
>>... but it doesn't work. A fileset doesn't accept a if inside, 
>>and a if does not accept a fileset inside, and so on ...
>>
>>How can I do this???
>>
>>Thomas
>>
>>
>>PS: I also found http://ant-contrib.sourceforge.net/fileset.html
>>but it just "didn't" work. (I downloaded/placed the contrib 
>>jar and added the line <taskdef 
>>resource="net/sf/antcontrib/antcontrib.properties">
>>but it still said, that the fileset doesnt know the "unless".)
>>
>>---------------------------------------------------------------------
>>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
>
>
>---------------------------------------------------------------------
>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