You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Donald Strong <ds...@agentissoftware.com> on 2004/03/29 05:43:33 UTC
Set a property is source files exist.
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
RE: Set a property is source files exist.
Posted by Donald Strong <ds...@agentissoftware.com>.
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
Re: Set a property is source files exist.
Posted by Peter Reilly <pe...@corvil.com>.
Excellent,
Peter
Matt Benson wrote:
>--- Peter Reilly <pe...@corvil.com> wrote:
>
>
>>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"/>
>>
>>
>
>Or, use setonempty="false" with <pathconvert> and skip
>the <condition>... ;)
>
>-Matt
>
>__________________________________
>Do you Yahoo!?
>Yahoo! Finance Tax Center - File online. File on time.
>http://taxes.yahoo.com/filing.html
>
>---------------------------------------------------------------------
>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
Re: Set a property is source files exist.
Posted by Matt Benson <gu...@yahoo.com>.
--- Peter Reilly <pe...@corvil.com> wrote:
> 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"/>
Or, use setonempty="false" with <pathconvert> and skip
the <condition>... ;)
-Matt
__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Set a property is source files exist.
Posted by Peter Reilly <pe...@corvil.com>.
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
Re: Set a property is source files exist.
Posted by Ivan Ivanov <ra...@yahoo.com>.
Donald,
take a look at ant's supported conditions
(http://ant.apache.org/manual/CoreTasks/condition.html)
and task
<available>(http://ant.apache.org/manual/CoreTasks/available.html)
I think you can use something like
<available file="${junit.test.source.dir}"
property="isTestsHere">
Good Luck Ivan
--- Donald Strong <ds...@agentissoftware.com> 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
>
__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org