ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Stewart" <>
Subject Re: Calling a cmd batch file from Ant
Date Wed, 28 May 2008 14:25:44 GMT
I have used the following to include the components specific to the
clients which I am building the code for.

There is the main build.xml file which then opens a file called
componentnames.txt, this file is opened and the component name extracted
and used to execute the appropriate build.xml for the conmponent. In
this way components can be treated like an object in that the component
"knows how to build itself".

Adding components is then achieved by adding the component name in to
the text file and providing the build.xml file for the component. The
main build file does not have to be modified in any way to add the new
functionality to the build. The target below is called supplying the
${} and a path to the root directory e.g. C:\Build in the
${component.path} property.

	<!-- This target calls the build.xml for each of the client
specific components -->	
	<target name="BuildComponents" description="Automatic build of
components specified in the file componentnames.txt in the client
directory." >

		<!-- load the componentnames file for later use -->
property="componentnames" failonerror="false" />
			<isset property="componentnames" />

			<!-- extract the component file names from the
/componentnames.txt file -->
			<ac:for delimiter="${line.separator}"
param="componentname" list="${componentnames}">
					<!-- Call the localdeploy for
component files -->
target="LocalDeploy" inheritAll="true" >
property="RemoteDeployComponent" />
							<!-- Call the
remotedeploy for component files -->
target="RemoteDeploy" inheritAll="true" >
				   <echo message="no components to
deploy." />

I've attached a screenshot which shows the directory structure, the
main build.xml is in the Build\build directory and extracts the
componentnames.txt file from the component\${} directory
which in the case of client3 contains:


These are then used to create the path to the component directory with
the build.xml e.g. C:\Build\component\client3\WebSelfService\build, this
is then used to call to the LocalDeploy and RemoteDeploy targets as

Note that I used failonerror="false" when opening the
componentnames.txt file as not all clients have components and the build
would fail if the file didn't exist.

Mike S.

>>> 28/05/2008 08:37:03 >>>
I am calling a dos batch file from an Ant script using the following
code :-

<property name="dos" location="c:/windows/system32/cmd.exe"/>

<exec executable="${dos}" dir="c:/build/">
          <arg value="CommonCommponent.bat"/>

On the assumption that I get the Microsoft Windows Copyright info
appear, I
assume the above commands are running ok. The only trouble is, the
/ commands in the batch file don't seen to get executed.

Batch file contents are :-

set component=common
ant -f %build.dir%/component.xml

Any help would be gratefully received.


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

View raw message