aspose file tools
The moose likes Ant, Maven and Other Build Tools and the fly likes (Anyone) using propertyfile ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Reply Bookmark "(Anyone) using propertyfile ?" Watch "(Anyone) using propertyfile ?" New topic
Author

(Anyone) using propertyfile ?

Sam Smoot
Ranch Hand

Joined: Apr 18, 2002
Posts: 237
Trying to use this in a build.xml for ANT:

According to the documentation in ANT, this should update the my.properties file with a current date stamp / information. I get zip.
HELP!


CNSS/NSA Infosec Professional,<br />Software Engineer
Greg Charles
Bartender

Joined: Oct 01, 2001
Posts: 1854

Looks like you found a mistake in their documentation. The line:
<entry key="anint" type="int" operation="+"/>
must have a "default" attribute to be valid. Try:
<entry key="anint" type="int" default="0" operation="+"/>
Or you can just comment it out, since you're only looking for the datestamp part.
Sam Smoot
Ranch Hand

Joined: Apr 18, 2002
Posts: 237
Ok.. took the line out... still nothing..
I do get this error:

Detected Java version: 1.3 in: c:\WebSphere\AppServer\java\jre
Detected OS: Windows 2000
parsing buildfile c:\ant\Project1Build.xml with URI = file:c:/ant/Project1Build.xml
Project base dir set to: C:\ant
BUILD FAILED
file:c:/ant/Project1Build.xml:28: Unexpected element "propertyfile"
at org.apache.tools.ant.helper.ProjectHelperImpl.parse(ProjectHelperImpl.java:170)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:117)
at org.apache.tools.ant.Main.runBuild(Main.java:597)
at org.apache.tools.ant.Main.start(Main.java:196)
at org.apache.tools.ant.Main.main(Main.java:235)
Total time: 1 second

The XML file is:

(And I thought Tying shoes was tough.)
[ February 12, 2003: Message edited by: Sam Smoot ]
Greg Charles
Bartender

Joined: Oct 01, 2001
Posts: 1854

Oh, I see. PropertyFile, unlike Property, is a task. It has to be part of a target to work.
Sam Smoot
Ranch Hand

Joined: Apr 18, 2002
Posts: 237
I did that before and had the same problem...
It works now...
Thanks!
Hann-Yu Chang
Greenhorn

Joined: Feb 17, 2004
Posts: 9
I am having the same problem. It appears as though the properties file is not being updated as the properties are being modified. Is there anyway to reload/refresh the file?
Objective is to be able to write to the properties file and read from it right away.
Brian Heisler
Greenhorn

Joined: Apr 13, 2001
Posts: 4
Try this...
setstate is the name of the target...
propertyfile is the name of the task inside the aforementioned target...
---start buildfile (build.xml) here----
<!-- ======================================================= -->
<!-- create a properties file for the build machine -->
<!-- ======================================================= -->
<target name="setstate" description="create prop file with environment variables on the build machine - to be accessed right away!">

<propertyfile file="homedirectory/Build.properties"
comment="Build Information">
<entry key="build.date"
type="date"
pattern="EEEE MMM dd, yyyy"
value="now"/>
<entry key="build.time"
type="date"
pattern="kk:mm:ss"
value="now"/>
<entry key="build.timestamp"
type="date"
pattern="MM-dd-yyyy' at 'HH:mm:ss"
value="now"/>
<entry key="build.host" value="${env.COMPUTERNAME}" />
<entry key="build.user.name" value="${user.name}" />
<entry key="build.os.name" value="${os.name}" />
</propertyfile>

</target>
---end buildfile (build.xml) here----
Hope this helps!
 
IntelliJ Java IDE
 
subject: (Anyone) using propertyfile ?
 
Threads others viewed
How to update the ant build script (build.xml) to get the latest code from the repository?
Build Number
Reading a property from a file
injecting a value into a variable from a build process
Build.properties
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture