ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: [genuine] RE: RemoteAnt / AntServer
Date Mon, 13 Jun 2005 12:08:34 GMT
Here are some snippets, I hope this will help you to get it to work. The documentation for
AntServer is quite poor, I agree. The example doesn't work because the runant-node is closed
with a runtarget node. Never theless here is the code that works for me. I'll write few words
to explain how to use it:

On the remote machine you need to start the remoteAnt Server. To do so run start.ant.server
on the remote machine.

<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="RMI" basedir="." default="jar">
	<!-- path to external jars -->
	<path id="classpath">
		<fileset dir="path/to/libs">
			<include name="**/*.*jar"/>
	<!-- This target launches a server. Blocking call! the server opens a socket and waits
for input. -->
	<target name="start.ant.server" depends="declare">
		<!-- make sure the ant-contrib--0.6.jar is in your classpath-->
		<taskdef resource="net/sf/antcontrib/">
			<classpath refid="classpath"/>
		<antserver port="12345" />
	<target name="remoteant">
		<echo message="Hello runant, ${build.type}"/>
		<sleep seconds="4"/>

Run these targets on the local machine to execute a task or buildfile on the remote machine.
Note: after running a single target, ie. exec.task.on.remote.ant.server, the AntServer needs
to be started again. To find out  why I started this thread:
	<!-- These targets execute a target specified in this buildfile given in the nested runtarget
node. -->
	<target name="exec.task.on.remote.ant.server" depends="declare">
		<remoteant machine="" port="12345" persistant="false" failonerror="true">
			<runtarget target="task.on.remote.machine">
				<property name="prop.type" value="respect!" />
	<!-- This target is excuted on the remote machine by the target above. -->
	<target name="task.on.remote.machine">
		<echo message="Hello task.on.remote.machine, ${prop.type}"/>
		<sleep seconds="3"/>
	<!-- This target runs a target from a buildfile on the remote machine. -->
	<target name="run.remote.buildfile" depends="declare">
		<remoteant machine="" port="12345" persistant="false" failonerror="true">
			<runant dir="." target="remoteant" antfile="yab.xml">
				<property name="build.type" value="respect!" />
				<reference refid="my.ref" torefid="inherited.ref" />

Am 10.06.2005 um 20:40 schrieb S I:

Please indulge us by posting a snippet of your code. I would really appreciate it.  For the
life of me, I still have not figured out what to make of the cryptic Antcontrib documention
written SO BADLY and ambiguously.  And the examples are very vague too.  I apologize for that.
 I'm just very frustrated with Antcontrib & its author who needs to take a course in writing.

I wanna be able from my winXP destop running my ant script to be able to stop Tomcat on the
linux server, unzip and dump my war files under tomcat/webapps and restart Tomcat.  I have
not been able to this and I'm not at all clear or sure what needs to be done on the xp side
and what exactly needs to be done on the linux server side?

So you will need to start an Ant-Server on the linux box. Then execute a buildfile as in "run.remote.buildfile"
that does unzipping and dumping of  your wars, etc  The buildfile would need to be on the
linux machine.

or define all the targets on in the buildfile on the win machine and use the "exec.task.on.remote.ant.server"

I hope this helps.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message