Here is a sample of my build file.
<target name="hotswap" depends="init" description="Compile and Hotswap changed classes">
<taskdef name="hotswap" classname="org.apache.tools.ant.taskdefs.Hotswap"/>
<mkdir dir="${build.classes.dir}"/> <tstamp>
<format property="class.stamp" pattern="MM/dd/yyyy hh:mm" />
</tstamp>
<echo message="timestamp = ${class.stamp}"/>
<javac .../>
<hotswap verbose="true" hotswap="true" hsaddress="9000">
<fileset dir="${build.classes.dir}" includes="**/*.class">
<date datetime="${class.stamp} AM" when="after"/>
</fileset>
</hotswap>
</target>
This is an example of the timestamp that is returned. Is there a way to get this to use seconds as well? The granularity doesn't seem good enough for my purpose.
[echo] timestamp = 04/02/2004 11:07
In the <date>, it requires the AM or PM part, which I'm just putting in by hand (which isn't good either). Is there a better way to select files that have changed in the classes dir since the javac has run?
Once I get this worked out, I'll clean up the task a little and make it available for everyone to try. (and provide some docs as well!)
Thanks, David
PS. I tested this by coding a specific class filename, since the date thing isn't working yet.
Thus Spoke Matt Benson:
http://ant.apache.org/manual/CoreTypes/selectors.html#dateselect
You would have to use a nested <format> element in your <tstamp> to create the date in the right format for the date selector, but aside from that I can't see any problems...
-Matt
--- [EMAIL PROTECTED] wrote:
This sounds good to me! The less grunt work I have to do in my task, the better! I grabbed teh 1.6.1 source release and built it. If you could point me to the <date> file selector you mention, it would help me a lot. I just poked around and it didn't jump out at me. I would like it if my task could just deal with a list of class files provided via some built-in filtering means.
Thanks, David
Quoting Matt Benson <[EMAIL PROTECTED]>:
Basically you should make any task as atomic asabout
possible. So all your task would need to know
is a <fileset>. Then it becomes the user'sproblem
how to select which files to include. One waymight
be to use a <tstamp>classes.
to set a baseline time, then compile, then use a
<date> file selector to get the updated classes. Another way might use ant-contrib's <outofdate> to
determine which sources should be recompiled. You
could then compile only those sources to some
temporary build area, then hotswap only those
The point is that others have designed ways inwhich
the files can be selected, so you gain maximumyour
flexibility (and minimum RESPONSIBILITY) the less
wonderedTask is expected to do.
-Matt
--- [EMAIL PROTECTED] wrote:
When I was toying with a separate task, I
butif <uptodate> could be use
somehow to create a <fileset>. I don't see now,
couldthat would sure be a nice
feature. Then, if I could assign an ID so I
dirmake a <fileset> of files
that aren't uptodate, run the compile, then take
that same <fileset> as input
to the <hotswap> target.
The idea of a timestamp file could work. The
sequence might be something like.
<touch file="timestamp"/>
<javac .../>
<hotswap classesdir="foo" host="localhost"
port="9000" timefile="timestamp">
<patternset>
... some pattern to apply to the classes
in... </patternset> </hotswap>
That way, the hotswap task would check the files
dothe classes dir based on the patternset and/or the timestamp.
Seriously, I'm open to feedback. I might as well
it right the first time!
David
Quoting Steve Loughran <[EMAIL PROTECTED]>:
__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway http://promotions.yahoo.com/design_giveaway/