You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Suzanne Dorman <su...@segsoftware.com> on 2006/10/04 15:30:44 UTC
Parsing directory names
I have the following directory structure:
2005_1.0
filea
fileb
2005_1.1
filec
2005_1.1.1
filed
2005_2.0
filee
My build needs to determine which files to zip based on the directory name.
If the user specifies 1.1, I need to include all files in the 2005_1.0 and
2005_1.1 directories but not the other directories (their version numbers
are higher). In order to write the logic to determine the proper
directories, I need to parse the directory names.
I first need to separate out the '2005' as a variable. I then need
everything after the underscore as another variable (we'll call it
$version). Once I have $version, I may need to separate out the characters
separated by '.' to determine if the version is higher or lower than the
user specified value.
I can get the list of directory names and put them in a foreach without any
problem but I don't know how to parse the string I get. In fact, I can't
find anything for string manipulation in Ant or ant-contrib. Is there such
a thing?
Thanks in advance for any help,
Suzanne Dorman
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Parsing directory names
Posted by Matt Benson <gu...@yahoo.com>.
--- Dominique Devienne <dd...@gmail.com> wrote:
> On 10/4/06, Suzanne Dorman
> <su...@segsoftware.com> wrote:
[SNIP]
> > I can get the list of directory names and put them
> in a foreach without any
> > problem but I don't know how to parse the string I
> get. In fact, I can't
> > find anything for string manipulation in Ant or
> ant-contrib. Is there such
> > a thing?
>
> Yes, but in convoluted ways only. I'd do it in Java
> as a custom task
> (defining a <path> for example, or a new resource
> collection in 1.7),
> or I'd use a <script>. Ant now has a DeweyDecimal
> utility (which
> hopefully implement Comparable). That's the jist of
> it ;-) Sorry,
> can't help more than by giving high level hints.
I like this; in fact it seem entirely natural that,
Ant 1.7, having ResourceCollections,
ResourceComparators, and ResourceSelectors, should
also have a compare ResourceSelector that uses a
Comparison "when" EA to select Resources that are
eq/ne/gt/lt/ge/le a given resource according to
specified ResourceComparators. I will try to get this
in soon with an example that speaks to this use case.
-Matt
> --DD
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Parsing directory names
Posted by Dominique Devienne <dd...@gmail.com>.
On 10/4/06, Suzanne Dorman <su...@segsoftware.com> wrote:
> I have the following directory structure:
>
> 2005_1.0
> filea
> fileb
> 2005_1.1
> filec
> 2005_1.1.1
> filed
> 2005_2.0
> filee
>
>
> My build needs to determine which files to zip based on the directory name.
> If the user specifies 1.1, I need to include all files in the 2005_1.0 and
> 2005_1.1 directories but not the other directories (their version numbers
> are higher). In order to write the logic to determine the proper
> directories, I need to parse the directory names.
>
> I first need to separate out the '2005' as a variable. I then need
> everything after the underscore as another variable (we'll call it
> $version). Once I have $version, I may need to separate out the characters
> separated by '.' to determine if the version is higher or lower than the
> user specified value.
>
> I can get the list of directory names and put them in a foreach without any
> problem but I don't know how to parse the string I get. In fact, I can't
> find anything for string manipulation in Ant or ant-contrib. Is there such
> a thing?
Yes, but in convoluted ways only. I'd do it in Java as a custom task
(defining a <path> for example, or a new resource collection in 1.7),
or I'd use a <script>. Ant now has a DeweyDecimal utility (which
hopefully implement Comparable). That's the jist of it ;-) Sorry,
can't help more than by giving high level hints. --DD
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org