build.xml忽略<echo>标签和if选项

时间:2015-05-29 20:20:10

标签: ant build.xml sencha-cmd

我有一个sencha Ext.js项目,我正在尝试获取用户输入并根据我build.xml文件中的用户输入采取行动。

这是我的build.xml

<?xml version="1.0" encoding="utf-8"?>
<project xmlns:if="ant:if" xmlns:unless="ant:unless" name="PSOGN" default=".help">
     <import file="${basedir}/.sencha/app/build-impl.xml"/>
     <target name="-after-build">
        <echo>57 ...</echo>
        <property name="realperl" value="/usr/bin/perl"/>
        <echo>59 ...</echo>
        <exec executable="/bin/hostname" outputproperty="myhost">
            <arg value="-s"/>
        </exec>
        <echo>64 ...</echo>
        <exec executable="${realperl}" outputproperty="env">
            <arg value="../bin/getCf.pl"/>
            <arg value="--config"/>
            <arg value="../etc/config/currentCf"/>
            <arg value="ENV"/>
        </exec>
        <echo>70 ...</echo>
        <input message="Install ${env} version on ${myhost}?" addproperty="install" validargs="y,n" />
        <echo>72 ...</echo>
        <condition property="doinstall">
                <equals arg1="${install}" arg2="y" />
            </condition>
        <echo>Hello ...</echo>
        <exec executable="${realperl}" outputproperty="htdocspath">
            <arg value="../bin/getCf.pl"/>
            <arg value="--config"/>
            <arg value="../etc/config/currentCf"/>
            <arg value="HTDOCSPATH"/>
        </exec>
        <echo>do install is ${doinstall}</echo>
        <echo if:true="${doinstall}">Please wait. Executing rsync to ${htdocspath}. Output logged to /tmp/rsync.log.</echo>
        <echo if:false="${doinstall}">Skipping rsync to ${htdocspath}.</echo>
        <exec executable="/usr/local/bin/rsync" if:true="${doinstall}">
            <arg value="--exclude='*.log'" />
            <arg value="--chmod=ugo=rwX" />
            <arg value="-rltDq" />
            <arg value="../info"/>
            <arg value="../sbin"/>
            <arg value="../bin"/>
            <arg value="../cec"/>
            <arg value="../cec.list.html"/>
            <arg value="../cgi"/>
            <arg value="../common"/>
            <arg value="../dblib"/>
            <arg value="../etc"/>
            <arg value="../ext-2.3.0"/>
            <arg value="../framework"/>
            <arg value="../help"/>
            <arg value="../icon-loading-animated.gif"/>
            <arg value="../images"/>
            <arg value="../img"/>
            <arg value="../include"/>
            <arg value="../index.shtml"/>
            <arg value="../kicker"/>
            <arg value="../lib"/>
            <arg value="../msgs"/>
            <arg value="../src"/>
            <arg value="../thingold"/>
            <arg value="../thing"/>
            <arg value="${htdocspath}"/>
            <redirector output="/tmp/rsync.log" alwayslog="true"/>  
        </exec>
    </target>
 </project>

当我运行调用sencha app build的{​​{1}}时,我只能从ant获得此输出:

build.xml

我的Install Dev version on tools-dev1? (y, n) 标签没有输出,如果我回答'n',我可以执行<echo...命令。我在这里做错了什么?

1 个答案:

答案 0 :(得分:1)

我简化了build.xml

<project xmlns:if="ant:if" xmlns:unless="ant:unless" name="PSOGN" >

        <input message="Install ?" addproperty="install" validargs="y,n" />
        <condition property="doinstall">
                <equals arg1="${install}" arg2="y" />
        </condition>
        <echo>do install is ${doinstall}</echo>
        <echo if:true="${doinstall}">Please wait. Executing rsync</echo>
        <echo unless:true="${doinstall}">Skipping rsync </echo>
        <exec executable="echo" if:true="${doinstall}">
            <arg value="ECHO IS EXECUTED" />
            <redirector output="./rsync.log" alwayslog="true"/>  
        </exec>

 </project>

我将if:false替换为unless:true

<echo unless:true="${doinstall}">Skipping rsync </echo>

一切正常:

oleg@oleg-ThinkPad-X201:~/temp/aa$ ant
Buildfile: /home/oleg/temp/aa/build.xml
    [input] Install ? (y, n)
y
     [echo] do install is true
     [echo] Please wait. Executing rsync
     [exec] ECHO IS EXECUTED

BUILD SUCCESSFUL
Total time: 2 seconds
oleg@oleg-ThinkPad-X201:~/temp/aa$ ant
Buildfile: /home/oleg/temp/aa/build.xml
    [input] Install ? (y, n)
n
     [echo] do install is ${doinstall}
     [echo] Skipping rsync 

BUILD SUCCESSFUL
Total time: 2 seconds