When I compile my project in Netbeans, I want to automatically generate a file that includes a build number that automatically increments and date, so I added the following to my projects build.xml file.
<target name="-pre-jar" >
<propertyfile file="${src.dir}\buildstring.txt" >
<entry key="devbuild" value="1" type="int" operation="+"/>
<entry key="devbuildtime" type="date" value="now" pattern="yyyy MM dd hh_mm" />
</propertyfile>
</target>
When the Ant task executes, Ant automatically adds a date stamp as the first line of the file
#Tue, 12 Jun 2012 16:09:24 -0500
devbuild=8
devbuildtime=2012 06 12 04_09
Is there any way to stop Ant from automatically adding the first line with the date comment?
The PropertyFile Ant task is implemented using a java.util.Properties object. The
Properties.store()method is documented with the following note:Therefore, the date comment cannot be disabled using the
PropertyFiletask. Removing the date comment would require a different solution, such as post-processing the properties file or writing the properties file using a different technique (for example, using an Ant script or custom Ant task).See: Remove comments in properties file java