Re: [jug-discussion] Appending a new property to the end of a property file?

2005-02-27 Thread Erik Hatcher
propertyfile uses Java's on java.util.Properties to write the file, 
so comments, except for a one-line header, get removed.  This is a 
frequent annoyance that folks encounter.

But, since you'll be happy with an append, you can do this:
echo file=file.properties append=true
  prop=${val}
/echo
Ant expands ${} property references.  You'll need to be sure that the 
text is appropriate for an .properties file (escaped for special 
characters and all).  And if you need to insert new lines, use 
${line.separator} (a JVM system property that Ant makes handy).

Another alternative would be to use a master .properties file with 
@TOKENS in it and use a filtering copy to replace tokens in the copy 
process.

Erik
On Feb 27, 2005, at 2:10 AM, Chad Woolley wrote:
Hi,
Does anyone know how to prevent the Ant propertyfile task from 
randomly rearranging your property file and whacking all the comments?

Or alternately, some simple ant/maven based solution that just lets 
you append a new property to the end of a file?  I tried the 
replaceregexp task, but I'm not good enough with regexp to know how to 
append to the EOF.

I know I could write a program/task/plugin to do this, but I can't 
believe there's nothing out there that I could make work out of the 
box with a little tweaking...

Many thanks,
Chad
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: [jug-discussion] Appending a new property to the end of a property file?

2005-02-27 Thread Drew Davidson
Chad Woolley wrote:
Does anyone know how to prevent the Ant propertyfile task from 
randomly rearranging your property file and whacking all the comments?

rm -fr $ANT_HOME
Or alternately, some simple ant/maven based solution that just lets 
you append a new property to the end of a file?  I tried the 
replaceregexp task, but I'm not good enough with regexp to know how to 
append to the EOF.

I wouldn't have been a bastard with the above reply unless I had some 
solution :-)

I have an ant task that writes a property file based on a prefix.  The 
source is attached, as well as the taskdef jar.  Since this might not be 
100% what you want you can adapt this as a quick start rather than 
having to start from scratch.

here's how to use the task:
   taskdef resource=org/ognl/ant/taskdefs/ognl-ant.properties
   classpath
   pathelement location=${system.lib}/ognl-ant-0.0.2.jar/
   /classpath
   /taskdef
Example usage where I want to dump all the properties with the prefix 
hibernate:

   property name=hibernate.connection.driver_class  
value=${database.driver}/
   property name=hibernate.connection.url   
value=${database.url}/
   property name=hibernate.connection.username  
value=${database.username}/
   property name=hibernate.connection.password  
value=${database.password}/
   property name=hibernate.default_schema   
value=${database.schema}/
   property name=hibernate.show_sql 
value=${database.show_sql}/

   mkdir dir=${output.properties}/
   propertydump comment=Hibernate database configuration
file=${output.properties}/hibernate.propertiesprefix=hibernate./

I know I could write a program/task/plugin to do this, but I can't 
believe there's nothing out there that I could make work out of the 
box with a little tweaking...
I don't believe so.  I looked around also.
- Drew
--
+-+
 Drew Davidson | OGNL Technology 
+-+
|  Email: [EMAIL PROTECTED]  /
|Web: http://www.ognl.org   /
|Vox: (520) 531-1966   
|Fax: (520) 531-1965\
| Mobile: (520) 405-2967 \
+-+


ognl-ant-0.0.2.jar
Description: Binary data
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Re: [jug-discussion] Appending a new property to the end of a property file?

2005-02-27 Thread Erik Hatcher
On Feb 27, 2005, at 9:28 AM, Drew Davidson wrote:
Chad Woolley wrote:
Does anyone know how to prevent the Ant propertyfile task from 
randomly rearranging your property file and whacking all the 
comments?

rm -fr $ANT_HOME
Or alternately, some simple ant/maven based solution that just lets 
you append a new property to the end of a file?  I tried the 
replaceregexp task, but I'm not good enough with regexp to know how 
to append to the EOF.

I wouldn't have been a bastard with the above reply unless I had some 
solution :-)
Perhaps you should RTFM :))
I have an ant task that writes a property file based on a prefix.
For a frequent basher of Ant, it might behoove you to know the enemy 
well:

project name=propfile
  property name=hibernate.whatever value=Drew/
  echoproperties destfile=hibernate.properties prefix=hibernate./
/project
True that this misses the original point, as does your task, of keeping 
the comments intact.  echoproperties also supports the 
propertyset's, which allow lots of control over which properties are 
selected, not just by prefix.

Erik
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: [jug-discussion] Appending a new property to the end of a property file?

2005-02-27 Thread Drew Davidson
Erik Hatcher wrote:
On Feb 27, 2005, at 9:28 AM, Drew Davidson wrote:
I have an ant task that writes a property file based on a prefix.

For a frequent basher of Ant, it might behoove you to know the enemy 
well:

project name=propfile
  property name=hibernate.whatever value=Drew/
  echoproperties destfile=hibernate.properties prefix=hibernate./
/project
True that this misses the original point, as does your task, of 
keeping the comments intact.  echoproperties also supports the 
propertyset's, which allow lots of control over which properties are 
selected, not just by prefix.

Great, just try to find it in
   http://ant.apache.org/manual/index.html
Oh, it's in Optional Tasks: what does that mean?  Only with the ant 
optional jar?  How do I know someone will have that who tries to use my 
build file?  Why is it optional?  Which Ant developer made the arbitrary 
decision that this echoproperties gem should be optional instead of 
core?

The documentation is IMPOSSIBLE TO NAVIGATE.  I wish that I'd saved 
myself the time and effort to write this because Ant's documentation was 
written and organized by a 4 year old.  Thanks for making me angrier.

As to For a frequent basher of Ant, it might behoove you to know the 
enemy well I really don't want to have to grovel through a big, 
unorganized heap of incredibly badly written documentation to find 
this.  The fact that I didn't find this (and I was looking) and Chad 
didn't find it might make you think that maybe it's the fault of the 
lousy documentation, not the searcher.  The docs are all just a big bag 
of stuff with no organizations or explainations.  How the hell am I 
supposed to know to look in Optional Tasks instead of Core Tasks???

- Drew
--
+-+
 Drew Davidson | OGNL Technology 
+-+
|  Email: [EMAIL PROTECTED]  /
|Web: http://www.ognl.org   /
|Vox: (520) 531-1966   
|Fax: (520) 531-1965\
| Mobile: (520) 405-2967 \
+-+
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: [jug-discussion] Appending a new property to the end of a property file?

2005-02-27 Thread Erik Hatcher
On Feb 27, 2005, at 10:12 AM, Drew Davidson wrote:
Erik Hatcher wrote:
On Feb 27, 2005, at 9:28 AM, Drew Davidson wrote:
I have an ant task that writes a property file based on a prefix.

For a frequent basher of Ant, it might behoove you to know the enemy 
well:

project name=propfile
  property name=hibernate.whatever value=Drew/
  echoproperties destfile=hibernate.properties 
prefix=hibernate./
/project

True that this misses the original point, as does your task, of 
keeping the comments intact.  echoproperties also supports the 
propertyset's, which allow lots of control over which properties 
are selected, not just by prefix.

Great, just try to find it in
   http://ant.apache.org/manual/index.html
Well, I clicked on the Overview of Ant Tasks link to get to this page:
http://ant.apache.org/manual/tasksoverview.html
and there is a property tasks area.  Echoproperties is listed there.
I'm not going to defend Ant's documentation structure - I agree its 
horrible.  For the Ant book I spent a great deal of time building an 
XDoclet task reference generator (it's in Ant's proposal/xdocs CVS 
directory).  Appendix E of our book was entirely generated.  In that 
effort, I meticulously annotated Ant's task source code with @tags to 
provide the necessary metadata that could not be gleaned otherwise.  
That effort in no way fixed the structure of the documentation.

Oh, it's in Optional Tasks: what does that mean?  Only with the ant 
optional jar?  How do I know someone will have that who tries to use 
my build file?  Why is it optional?  Which Ant developer made the 
arbitrary decision that this echoproperties gem should be optional 
instead of core?
All of these questions have been discussed in the Ant e-mail list.  The 
short answer is that in Ant 1.6+, all optional stuff is included in 
Ant by default - nothing needs to be added unless there are 3rd party 
dependencies (junit.jar, for example) that don't ship with Ant but are 
used by some tasks.

The documentation is IMPOSSIBLE TO NAVIGATE.  I wish that I'd saved 
myself the time and effort to write this because Ant's documentation 
was written and organized by a 4 year old.  Thanks for making me 
angrier.
I personally feel guilty and responsible for the state of Ant's 
documentation.  The info is actually there, it needs someone with a 
keen sense of how to structure it better though.

I know these rhetorical comments will strike more nerves, but did you 
ask on the Ant list (or this list?) if there was a way to write 
property files from all Ant properties?  Did you consider contributing 
your task to Ant itself since it is generic and not tied to OGNL 
itself?  Can't we be one big happy family and get along?  :)

As to For a frequent basher of Ant, it might behoove you to know the 
enemy well I really don't want to have to grovel through a big, 
unorganized heap of incredibly badly written documentation to find 
this.  The fact that I didn't find this (and I was looking) and Chad 
didn't find it might make you think that maybe it's the fault of the 
lousy documentation, not the searcher.  The docs are all just a big 
bag of stuff with no organizations or explainations.  How the hell am 
I supposed to know to look in Optional Tasks instead of Core 
Tasks???
No argument there... it's a mess.  The point of the overview of tasks 
page was to build a bit more structure to it, though it is quite 
inadequate.  We used to have an Ant committer on board that worked on 
keeping documentation up to date and started this restructuring, but 
unfortunately she's no longer active.

Erik
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: [jug-discussion] Appending a new property to the end of a property file?

2005-02-27 Thread Erik Hatcher
On Feb 27, 2005, at 10:12 AM, Drew Davidson wrote:
The documentation is IMPOSSIBLE TO NAVIGATE.
I had to fiddle with the search terms to find it, but the search terms  
seem logical for the purpose:

	http://www.google.com/search? 
client=safarirls=enq=ant+property+file+prefixie=UTF-8oe=UTF-8

You used the attribute prefix in your task, and that is the key to  
get echoproperties to appear.

Again, I concur with the state of Ant's documentation.  Is there any  
project (besides OGNL :) that is documented as well as it should be?   
And yes, OGNL is very well documented!  Kudos, Drew!  Point me to the  
best thats out there, I'd love to have some examples to base from.

Erik
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: [jug-discussion] Appending a new property to the end of a property file?

2005-02-27 Thread Erik Hatcher
On Feb 27, 2005, at 12:53 PM, Dennis Sosnoski wrote:
Drew Davidson wrote:
Great, just try to find it in
   http://ant.apache.org/manual/index.html
Oh, it's in Optional Tasks: what does that mean?  Only with the ant 
optional jar?  How do I know someone will have that who tries to use 
my build file?  Why is it optional?  Which Ant developer made the 
arbitrary decision that this echoproperties gem should be 
optional instead of core?

The documentation is IMPOSSIBLE TO NAVIGATE.  I wish that I'd saved 
myself the time and effort to write this because Ant's documentation 
was written and organized by a 4 year old.  Thanks for making me 
angrier.


Maybe the intent is to motivate you to buy a book on Ant - the JBoss 
principle of making crappy documentation available for free, so that 
you'll get sucked in and then have to pay for something better. I 
think somebody wrote one on Ant a while ago... ;-)
Yeah, I hear that lizard cover one from O'Reilly is where it's at!  :)
Maybe you folks downloading Ant over dialup will have noticed that its 
a pretty large download... thanks to Appendix E of JDwA being added to 
the distribution.  JDwA is way past its prime right now, and if the Ant 
team wanted to simply HTMLify our book and make it the built-in 
documentation I'd be all for it, though it'd need a lot of updating to 
account for the new features.  Steve is working on the 2nd edition as 
we speak.  It's a struggle with me do I spend my time on writing a 
book or improving the built-in stuff.  What is better for the 
community?

Erik
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]