build.xml ignoring <echo> tags and if options

我与影子孤独终老i 提交于 2019-12-13 07:25:55

问题


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.

Here's my 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>

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)

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?


回答1:


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>

and I replaced if:false with unless:true

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

Everything works fine:

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


来源:https://stackoverflow.com/questions/30538385/build-xml-ignoring-echo-tags-and-if-options

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!