我正在尝试自动化BAR文件创建我想接受来自用户的多个值,将其存储在某个列表或数组中,然后单独使用ANT脚本中的所有变量。以下是我正在尝试的脚本:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:ac="antlib:net.sf.antcontrib"
name="AirLineReservation" default="acceptInputs">
<target name="run" description="BAR File Generation">
<property name="toolkit.home" value="C:/Program Files (x86)/IBM/WMBT800" />
<property name="ant.library.dir" value="C:/Manju/apache-ant-1.8.4/lib"/>
</target>
<target name="acceptInputs" description="Accepts inputs from user">
<taskdef
uri="antlib:net.sf.antcontrib"
resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${ant.library.dir}/ant-contrib-1.0b3.jar" />
</classpath>
</taskdef>
<input message="Enter Workspace Directory" addproperty="workspace.dir"/>
<echo message= " Workspace dir : ${workspace.dir} "/>
<input message="Enter Project name" addproperty="project.name"/>
<echo message= "Project Name : ${project.name} "/>
<input message="Enter Name of BAR file to be created" addproperty="bar.name"/>
<echo message= " Bar File Name : ${bar.name} "/>
<input message="Enter number of resources You want to add ( In Numbers )" addproperty="numberofresources"/>
<echo message= " Number of Resources : ${numberofresources} "/>
<ac:for param="i" end="${numberofresources}">
<sequential>
<input message="Enter Resource Name" addproperty="resource@{i}"/>
<echo>Resource: resource@{i} : ${resource@{i}}</echo>
</sequential>
</ac:for>
<echo message="Building the Message Broker Project @ ${workspace.dir}" />
<exec executable="${toolkit.home}/mqsicreatebar.exe" failonerror="true">
<arg value="-data" />
<arg value="${workspace.dir}" />
<arg value="-b" />
<arg value="${bar.name}" />
<!-- List all the message flow projects -->
<arg value="-p" />
<arg value="${project.name}" />
<!-- List all the files to be included in the archive -->
<arg value="-o" />
<ac:for param="i" end="${numberofresources}">
<sequential>
<arg value="${resource@i}" />
</sequential>
</ac:for>
</exec>
</target>
</project>
在上面的脚本中,需要将我从用户接受的所有资源作为参数传递。 exec不允许嵌套for循环。 所以帮我把资源的所有值作为参数传递给exec。