ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ivan Ivanov <rambiusparkisan...@yahoo.com>
Subject Re: Excluding path from another path
Date Fri, 20 Feb 2004 13:10:13 GMT
Antoine,

Thank you for your advice. I used several selectors
and now my build.xml is much more organized. I did in
detail the following

1) I create selector "test.lib"...
        <selector id="test.lib" description="Describes
jars needed only for testing">
            <or>
                <filename name="aspectjrt-1.0.6.jar"/>
                <filename
name="cactus-1.5-beta1.jar"/>
                <filename
name="cactus-ant-1.5-beta1.jar"/>
                <filename
name="commons-httpclient-2.0-beta2.jar"/>
                <filename
name="commons-logging-1.0.3.jar"/>
                <filename name="httpunit-1.5.3.jar"/>
                <filename name="junit-3.8.1.jar"/>
                <filename name="nekohtml-0.7.4.jar"/>
            </or>
        </selector>

2) ... and selector "production.lib":
        <selector id="production.lib"
description="Describes jars needed by arcade">
            <not>
                <selector refid="test.lib"/>
            </not>
        </selector>

3) Two additional selectors, containg mysql and oracle
jdbc drivers, so that when I make a distribution for
one of these database to easily exclude the driver of
the other:
        <selector id="mysql.driver" description="MySQL
jdbc driver">
            <filename name="mySQLdriver.jar"/>
        </selector>

        <selector id="oracle.driver"
description="Oracle jdbc driver">
            <filename name="classes*.zip"/>
        </selector>

4) Next, I define test.classpath and compile.classpath
simply with this:
        <path id="test.classpath">
            <fileset dir="${project.lib}"
defaultexcludes="yes">
                    <selector refid="test.lib"/>
            </fileset>
        </path>

        <path id="compile.classpath">
            <fileset dir="${project.lib}"
defaultexcludes="yes">
                <selector refid="production.lib"/>
            </fileset>
        </path>

Of course, it is described how to reuse paths in
http://ant.apache.org/manual/using.html#references,
but
it was for important for me selector reusing. For
example in the lib attribute of war task in my
distribution target, now I have
                <and>
                    <selector refid="production.lib"/>
                    <not>
                        <selector
refid="oracle.driver"/>
                    </not>
                </and>
when I create a distribution for mysql and for an
oracle one I have
                <and>
                    <selector refid="production.lib"/>
                    <not>
                        <selector
refid="mysql.driver"/>
                    </not>
                </and>

So thank you very much once again for taking time to
help me. 

I also double checked
http://ant.apache.org/manual/using.html#references and
there is nothing about selectors. If you don't mind,
it will be good to add after examples with classpaths
something of the kind:

If you want to control your path like structures
better (or have fine-grained control, etc) you can use
selectors....

and give some examples of selectors and <and>-ing,
<or>-ing them.

If you think that this is a good idea, I can think of
such examples, write them with some explanations and
send them back to you.

Regards Ivan Ivanov

--- Antoine_LÚvy-Lambert <antoine@antbuild.com> wrote:
> Hi Ivan,
> 
> you need to define selectors with id and refer to
> them with refid.
> 
> NB ant's own build file is a good source of
> inspiration.
> 
> I also saw that on the manual page talking about
> references, there is no 
> mention of selectors (or I misread).
> http://ant.apache.org/manual/using.html#references
> 
> Now for you :
> 
> Something like
> 
> <selector id="mytestjars">
>     <or>
>        <filename name="test1.jar"/>
>        <filename name="test2.jar"/>
>        <filename name="test3.jar"/>
>        <filename name="test4.jar"/>
>    </or>
> </selector>
> 
> 
> <selector id="myprodjars">
>     <or>
>        <filename name="prod1.jar"/>
>        <filename name="prod2.jar"/>
>        <filename name="prod3.jar"/>
>        <filename name="prod4.jar"/>
>    </or>
> </selector>
> 
> <fileset id="f1" dir="lib">
>      <or>
>     <selector refid="mytestjars"/>
>     <selector refid="myprodjars"/>
>     </or>
> </fileset>
> 
> <fileset id="f2" dir="lib">
>     <selector refid="myprodjars"/>
> </fileset>
> 
> 
> or
> <fileset id="f2" dir="lib">
>     <and>
>         <not><selector refid="mytestjars"/></not>
>         <selector refid="alljars"/>
> </and>
> </fileset>
> 
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools

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


Mime
View raw message