You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Gao Lin <ao...@gmail.com> on 2011/07/04 04:59:51 UTC
How to define a path according to a property
Hi:
I have a requirement to define a path according to a property.
the command line: ant compile
will use the path :
<path id="test.lib.path.id">
<fileset dir="${lib.dir}/test1">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${lib.dir}/test2">
<include name="**/*.jar"/>
</fileset>
</path>
and the command line: ant -Dtest=true compile
will use the following path:
<path id="test.lib.path.id">
<fileset dir="${lib.dir}/test3">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${lib.dir}/test4">
<include name="**/*.jar"/>
</fileset>
</path>
There are many compile targets will use the path: test.lib.path.id, so
it would be better to define the path a little dynamically, like:
<path id="test.lib.path.id" if="test">
...
</path>
<path id="test.lib.path.id" unless="test">
...
</path>
but I think path does not support this attribute, right?
--
Thanks and Best Regards
aoingl@gmail.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: How to define a path according to a property
Posted by Parag Doke <pa...@gmail.com>.
Hi there.
My 1st attempt at answering a question on this list ... so apologies
if I make mistakes.
I believe patternsets do have conditional attributes. See this link:
http://ant.apache.org/manual/Types/patternset.html
Quoting from that page:
>>>>>
Patterns can be grouped to sets and later be referenced by their id
attribute. They are defined via a patternset element, which can appear
nested into a FileSet or a directory-based task that constitutes an
implicit FileSet. In addition, patternsets can be defined as a stand
alone element at the same level as target — i.e., as children of
project as well as as children of target.
<<<<<
The nested include element supports attributes "if" and "unless".
Hope this helps.
Thanks,
Parag Doke
Save paper, save trees. Do not print emails/documents unless
absolutely necessary.
On Mon, Jul 4, 2011 at 8:29 AM, Gao Lin <ao...@gmail.com> wrote:
> Hi:
>
> I have a requirement to define a path according to a property.
>
> the command line: ant compile
> will use the path :
> <path id="test.lib.path.id">
> <fileset dir="${lib.dir}/test1">
> <include name="**/*.jar"/>
> </fileset>
> <fileset dir="${lib.dir}/test2">
> <include name="**/*.jar"/>
> </fileset>
> </path>
>
> and the command line: ant -Dtest=true compile
> will use the following path:
> <path id="test.lib.path.id">
> <fileset dir="${lib.dir}/test3">
> <include name="**/*.jar"/>
> </fileset>
> <fileset dir="${lib.dir}/test4">
> <include name="**/*.jar"/>
> </fileset>
> </path>
>
> There are many compile targets will use the path: test.lib.path.id, so
> it would be better to define the path a little dynamically, like:
>
> <path id="test.lib.path.id" if="test">
> ...
> </path>
>
> <path id="test.lib.path.id" unless="test">
> ...
> </path>
>
> but I think path does not support this attribute, right?
>
> --
> Thanks and Best Regards
>
> aoingl@gmail.com
>
> ---------------------------------------------------------------------
> 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