1
我需要为给定文件中的每一行执行一个ant任务。任何想法赞赏。如何为给定文件中的每一行执行一个ant任务?
我需要为给定文件中的每一行执行一个ant任务。任何想法赞赏。如何为给定文件中的每一行执行一个ant任务?
我有一个属性文件,它定义了需要运行的进程。这是全部在一行和逗号分隔,而不是你已经指定的多行。这answer显示如何遍历文件。
env.start=webserver:localhost, dataserver:localhost
然后在我的蚂蚁文件处理应用程序的执行,我有以下
<target name="start-all" description="Start all processes specified in target-info.properties:env.start">
<foreach list="${env.start}" trim="yes" param="process.and.host" target="-start-process"/>
</target>
<target name="-start-process">
<property name="colon.separated.pattern" value="([^:]*):([^:]*)"/>
<propertyregex property="process" input="${process.and.host}" regexp="${colon.separated.pattern}" select="\1"/>
<propertyregex property="host" input="${process.and.host}" regexp="${colon.separated.pattern}" select="\2"/>
<condition property="start.target" value="start-${process}" else="-start-process-ssh">
<equals arg1="${host}" arg2="localhost" trim="yes" casesensitive="no"/>
</condition>
<antcall target="${start.target}"/>
</target>
$ {} start.target然后在env.start属性定义例如
流程执行<target name="start-webserver" description="Start the webserver on this machine">
<echo>** Starting webserver **</echo>
<run-script dir="${project.base.dir}/apache-tomcat" script="${project.base.dir}/apache-tomcat/bin/startup" spawn="yes">
<args>
<env key="CATALINA_HOME" value="${project.base.dir}/apache-tomcat"/>
<env key="CATALINA_PID" value="${project.base.dir}/apache-tomcat/logs/pid_catalina"/>
</args>
</run-script>
</target>
<target name="start-dataserver" depends="decipher_caldb_password,check-event-seed,run-prestart-sql" description="Start the dataserver on this machine">
<run-calypso process="dataserver" class="calypsox.apps.startup.StartNOGUI" failonerror="yes"
args="-class com.calypso.apps.startup.StartDataServer"/>
</target>
我可以通过运行
开始env.start中定义的所有进程
你能举一个例子来说明你的意思是“给定文件中的每一行”吗? – JoseK 2010-08-06 13:08:11
当然,假设像一个文件: 参数1参数2参数3 param4 param5 param6 ... 我想蚂蚁读取该文件和参数传递给子任务。 – SorinS 2010-08-09 11:02:40