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