ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik Hatcher" <jakarta-...@ehatchersolutions.com>
Subject Re: Getting the filename from a property
Date Thu, 28 Feb 2002 04:22:41 GMT
----- Original Message -----
From: "Diane Holt" <holtdl@yahoo.com>
> > We gotta make things like this simpler,
>
> I agree.
>
> > perhaps with special property syntax similar to how MessageFormat stuff
> > works.
> >
> > ${propertyname,file,filename}
>
> I don't know anything about MessageFormat (and no time to look it up right
> now), so I'm not entirely sure what the above examples is supposed to be
> doing -- but I think I'd disagree with it, just on that fact alone (ie., I
> can't tell just by looking at it).

And folks can tell by looking at the <script> and <pathconvert> examples
you've provided what they are supposed to be doing?!  :)

No offense, as its not your fault, just the nature of the beast we're
dealing with.

> I think Ant works best when it avoids
> weird constructions like that that you can't just read and get an idea of
> what it's doing, even if you don't really know anything about it.

Well, the above syntax was just thrown out as food for thought.
MessageFormat is a java.text API that allows parameterized substitutions
into strings.  Its used for localization primarily, but is a great trick for
just having parameterized stuff.  For example:

error.message=Oops, you did not specify {0}

in a properties file allows programatic substitution of {0}.  This allows
text messages to be *out* of Java code, and only parameters fed in.  This is
exactly how we should be doing our error messages and any other text output
from Ant.  Is this kind of thing already in mutant or myrmidon?  I think its
at least in myrmidon, right?

But you can get even fancier so you can localize date formats:

date.field.error=The date {0,date,yyyy/MM/dd} is not acceptable.

Then you can feed in a Date object into the substitution and the formatting
will happen automagically.  Very sweet stuff actually.  In localization
scenarios, you'd have a different properties file, appropriately named, for
each country for example.

This mechanism is fairly known to Java developers, although the advanced
formatting may not be super prevalent - but not too foreign I don't believe.

So I don't think its quite as obtuse as you believe, for the Java domain,
that is. The "scripty" stuff you post is far more convoluted and wacky (and
just flat out not the way Ant should be done) - again, no offense intended,
you're doing a fantastic job of making Ant work well for you given what
you've got.

    Erik



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


Mime
View raw message