ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Donald Strong" <dstr...@agentissoftware.com>
Subject RE: Set a property is source files exist.
Date Wed, 31 Mar 2004 00:13:15 GMT
Thanks Peter and Matt, pathconvert is spot on.

Here is my code for those who are interested.

    <target name="check-for-testcode"
         depends="init" >

        <property name="junit.test.pattern"
                 value="*Test_${appserver.type}.java" />
        <fileset id="junit.test.source.id" dir="${junit.test.source.dir}">
            <include name="**/${junit.test.pattern}"/>
        </fileset>
        <pathconvert property="testcode-exists"
                        refid="junit.test.source.id"
                   setonempty="false"
                     targetos="unix"/>
    </target>

    <target name="perform-junittest"
         depends="check-for-testcode"
              if="testcode-exists" >
        ...
    </target>

> -----Original Message-----
> From: Peter Reilly [mailto:peter.reilly@corvil.com]
> Sent: Monday, 29 March 2004 6:05 PM
> To: Ant Users List
> Subject: Re: Set a property is source files exist.
>
>
> You can use a mixture of pathconvert and condition:
>
>     <mkdir dir="nofiles"/>
>     <fileset id="empty" dir="nofiles" includes="**/*.java"/>
>     <pathconvert property="nofiles.files" refid="empty" targetos="unix"/>
>     <echo>nofile.files is ${nofiles.files}</echo>
>     <condition property="files.present">
>       <not>
>         <equals arg1="" arg2="${nofiles.files}"/>
>       </not>
>     </condition>
>     <echo>files.present="${files.present}"</echo>
>
> Peter
>
> Donald Strong wrote:
>
> >Hi all,
> >
> >I want to set a property if a set of files is not empty.
> >
> >I can get the set of files using a FileSet but how do I
> >then detect that the set is not empty?
> >
> >    <fileset id="junit.test.source.id" dir="${junit.test.source.dir}">
> >        <include name="**/${junit.test.pattern}"/>
> >    </fileset>
> >
> >I have tried setting a property in the hope that it worked like classpath
> >but to no avail.
> >
> >    <property name="junit.test.source.list"
> refid="junit.test.source.id"/>
> >    <echo> Source directory   = ${junit.test.source.list}</echo>
> >
> >[echo] Source directory   = org.apache.tools.ant.types.FileSet@9be79a
> >
> >I have tried <uptodate> and <outofdate> but they only care whether the
> >target file is there. I don't have a target file. I have tried various
> >permutations with and without a dummy target file, but no dice.
> >
> >Hit me with inspired suggestions, please!
> >
> >Donald.
> >
> >---------------------------------------------------------------------
> >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