build.xml 忽略 <echo>标签和 if 选项 [英] build.xml ignoring <echo> tags and if options

查看:24
本文介绍了build.xml 忽略 <echo>标签和 if 选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a sencha Ext.js project and I am trying to get user input and take action based on that user input in my build.xml file.

这是我的 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>

当我运行调用 antsencha app build 时,我只能通过 build.xml 得到这个输出:

When I run sencha app build which invokes ant I only get this output from by build.xml:

Install Dev version on tools-dev1? (y, n)

我的 <echo... 标签没有输出,如果我回答n",我可以执行 rsync 命令.我在这里做错了什么?

There is no output from my <echo... tags and if I answer 'n' I can that the rsync command executes. What am I doing wrong here?

推荐答案

我简化了你的 build.xml

I simplified your 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>

然后我用 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

这篇关于build.xml 忽略 &lt;echo&gt;标签和 if 选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆