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.properties" prefix="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]