Via Java API you can use Project.getReference() for evaluating.
Here a little build file for testing:
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="test" basedir=".">
<fileset id="fs.exists" dir="."/>
<!-- fs.notexists does not exist :-) -->
<script language="javascript"> <![CDATA[
propName = "fs.exists";
fsExists = project.getReference(propName);
if (fsExists == null) {
project.setProperty(propName + ".exist", "false");
} else {
project.setProperty(propName + ".exist", "true");
}
propName = "fs.notexists";
fsExists = project.getReference(propName);
if (fsExists == null) {
project.setProperty(propName + ".exist", "false");
} else {
project.setProperty(propName + ".exist", "true");
}
]]></script>
<echo>
fileset 'fs.exists' does exist: ${fs.exists.exist}
fileset 'fs.notexists' does exist: ${fs.notexists.exist}
</echo>
</project>
C:\tmp\anttests\checkRefExists>ant
Buildfile: build.xml
[echo]
[echo] fileset 'fs.exists' does exist: true
[echo] fileset 'fs.notexists' does exist: false
[echo]
BUILD SUCCESSFUL
Total time: 2 seconds
Does that help?
Jan
> -----Original Message-----
> From: Oliver Wulff [mailto:oliver.wulff@zurich.ch]
> Sent: Monday, September 29, 2003 7:47 AM
> To: Ant Users List
> Subject: Antwort: RE: Antwort: AW: Check whether a fileset exist
>
>
>
>
>
>
> I'm using Greebo to download all jars from the Maven repository. I've
> extended Greebo to create a fileset automatically.
> We are using different technologies in Java like Corba, Axis,
> JBoss, ...
> For each one, you have to generate java source files and compile them.
> I've set up a pluggable build mechanism for Ant with different build
> modules for Corba, Axis, JBoss (XDoclet). You define which
> build modules
> you want to use in a properties file.
> In some circumstances, the automatically created fileset
> can't be used for
> compilation. That means, a build module should make the
> following decision:
> compile the sources with the fileset "orbix.libs" if exists
> otherwise use
> the default one. That means, the developer can either just do
> nothing and
> the automatically created fileset is used or he can define a fileset
> explicitly (in this example: "orbix.libs").
>
> Oliver
>
>
> ******************************************************************
> Oliver Wulff
> Zürich Versicherungs-Gesellschaft
> IA4, CoC Middleware
> Postfach, 8085 Zürich
> Telefon: +41- 1 628 58 07
> Fax: +41 - 1 623 58 07
> E-Mail: mailto:oliver.wulff@zurich.ch
>
>
>
>
>
>
> Jan.Materne@rzf.
>
>
> fin-nrw.de An:
> user@ant.apache.org
>
> Kopie:
>
>
> 29.09.2003 07:14 Thema: RE:
> Antwort: AW: Check whether a fileset exist
>
> Bitte antworten
>
>
> an "Ant Users
>
>
> List"
>
>
>
>
>
>
>
>
>
>
>
>
> Why do you want to check?
> Simply declare it on the beginning of the buildfile and use
> that where you
> want.
> The _content_ of that fileset is evaluated when it´s used,
> not when it´s
> declared.
>
>
> Jan
>
>
> > I really want to test if a fileset has been created or not. I
> > tried it with
> > <pathconvert> but it fails if the fileset doesn't exist. If
> > the fileset
> > doesn't exist the property shouldn't created.
> >
> > <pathconvert refid="contrib.fs" targetos="unix"
> property="my.fileset"
> > setOnEmpty="false" />
> >
> > Cheers
> > Oliver
> >
> > -----------------------------------
> >
> > I guess you mean you want to check whether a fileset contains
> > at least one
> > file. You can do this by using <pathconvert/> to transform create a
> > property
> > containing the files present in your fileset. Then you can use the
> > <condition/> task to compare the property obtained with the
> > empty string.
> > Look at the condition task docu in the manual.
> >
> > <project name="pathconvert">
> > <fileset dir="c:/dev/asf/ant" id="myfileset">
> > <include name="**/*.xyz"/>
> > </fileset>
> > <pathconvert refid="myfileset" targetos="unix"
> property="my.fileset"/>
> > <echo message="my.fileset is ${my.fileset}"/>
> > </project>
> >
> > Cheers,
> >
> > Antoine
> >
> > -----Ursprüngliche Nachricht-----
> > Von: Oliver Wulff [mailto:oliver.wulff@zurich.ch]
> > Gesendet: Donnerstag, 25. September 2003 21:04
> > An: ant-user@jakarta.apache.org
> > Betreff: Check whether a fileset exist
> >
> > Hi
> >
> > Can I check whether a fileset exist?
> >
> > Oliver
> >
> >
> >
> >
> >
> >
> >
> > ******************* BITTE BEACHTEN *******************
> > Diese Nachricht (wie auch allfällige Anhänge dazu) beinhaltet
> > möglicherweise vertrauliche oder gesetzlich geschützte Daten oder
> > Informationen. Zum Empfang derselben ist (sind) ausschliesslich die
> > genannte(n) Person(en) bestimmt. Falls Sie diese Nachricht
> > irrtümlicherweise erreicht hat, sind Sie höflich gebeten,
> diese unter
> > Ausschluss jeder Reproduktion zu zerstören und die absendende Person
> > umgehend zu benachrichtigen. Vielen Dank für Ihre Hilfe.
> >
> >
> >
> ---------------------------------------------------------------------
> > 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
>
|