Alex Rivera | Logout

adding comment in .properties files

Asked 2013-04-10T11:11:16.200
42

By using following block of code in build.xml file

<propertyfile file="default.properties" comment="Default properties">
   <entry key="source.dir" value="1" />
   <entry key="dir.publish" value="1" />
   <entry key="dir.publish.html" value="1" />
</propertyfile>

I am able to generate default.properties file with following file contents

source.dir=1
dir.publish=1
dir.publish.html=1

I want to know how can I add my comments in the generated file? E.g. the generated properties should have the following content:

# Default Configuration
source.dir=1
dir.publish=1
# Source Configuration
dir.publish.html=1

How can I do it dynamically using Ant's build.xml?

Edit
Report

1 Answer

1

According to the documentation of the PropertyFile task, you can append the generated properties to an existing file. You could have a properties file with just the comment line, and have the Ant task append the generated properties.

answered 2013-04-10T11:28:15.243

Your Answer