[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: determining a java classes compile time



Then again, if you only echo the build date to the screen while the build is being performed, that
doesn't really tell you anything useful, does it?  So I suppose you must mean you want to be able
to tell some days later when the last build was done.  There are 2 ways to do this.

1.  Look at the date/time stamp of your .war file.
2.  Add this to build.xml:

<buildnumber/>

I recommend you place it just after the javac task.  The buildnumber task will create a file
called build.number.  It's a "properties" kind of file.  Here's a sample of the contents:

#Build Number for ANT. Do not edit!
#Mon Feb 24 14:33:36 EST 2003
build.number=1303

If you place the buildnumber task after the javac task, then the file only gets updated if
everything compiles successfully.

Now that you have the build number and build date in a file, you can read it in your application
and display it somewhere, like on an 'about' screen or something.  Read the build.number property
like you would read any property file.  To get the date, though, you have to open it as a text
file, read it, and parse it manually.  Too bad they don't just put that info as a property instead
of a comment.

It's all in the ant manual.
http://ant.apache.org/manual/index.html

Ed

--- andexor <andexor@yahoo.com> wrote:
> Put this in yer build.xml file:
> 
> <tstamp prefix="ant.build.test">
>     <format property="date" pattern="MM/dd/yyyy HH:mm:ss"/>
> </tstamp>
> 
> It will create a series of properties like this:
> 
> ant.build.test.date=02/24/2003 14:33:30
> ant.build.test.DSTAMP=20030224
> ant.build.test.TODAY=February 24 2003
> ant.build.test.TSTAMP=1433
> 
> The "date" one follows the pattern specified above.  The others are created and formatted by
> Ant.
> 
> Then you can echo the properties to the screen if you want.
> 
> Ed
> 
> --- Wade Steele <wsteele3@csc.com> wrote:
> > 
> > I'm using ANT to build and deploy and application.  I want to be able to
> > determine the date and time that the build was completed.  Is there anyway
> > that I can read the modified time on a .class file?
> > 
> > Thanks,
> > 
> > Wade


=====

Come with me to Orlando in April for the 2nd Annual
Informational Meeting for The Christian Film Festival.
http://www.christianfilmfestival.org/orlando_volunteerschedule.php


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com