Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何为给定文件中的每一行执行ant任务?_Ant - Fatal编程技术网

如何为给定文件中的每一行执行ant任务?

如何为给定文件中的每一行执行ant任务?,ant,Ant,我需要为给定文件中的每一行执行一个ant任务。任何想法都值得赞赏 我有一个属性文件,它定义了需要运行的进程。这都是在一行上,以逗号分隔,而不是您指定的多行。这显示了如何迭代文件 env.start=webserver:localhost, dataserver:localhost 然后在处理应用程序执行的ant文件中,我有以下内容 <target name="start-all" description="Start all processes specified in target-i

我需要为给定文件中的每一行执行一个ant任务。任何想法都值得赞赏

我有一个属性文件,它定义了需要运行的进程。这都是在一行上,以逗号分隔,而不是您指定的多行。这显示了如何迭代文件

env.start=webserver:localhost, dataserver:localhost
然后在处理应用程序执行的ant文件中,我有以下内容

<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>

你能举例说明“给定文件中的每一行”是什么意思吗?当然,假设一个文件如下:param1 param2 param3 param4 param5 param6。。。我希望ant读取该文件并将参数传递给子任务。
<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>
ant -f run.xml start-all