2009-11-19 20 views
7

在下面ph​​ing XML中,「skel中」目標裏面我檢查,如果配置了應用程序,如果它不那麼我所說的配置目標,然後將配置應用到幾個文件。目標通過<phingcall>叫不設置屬性在調用目標

的問題是,物業db.host的phingcall後沒有設置,即使它是在propertyprompt後進行設置。

我錯過了什麼?

<!-- base configuration --> 
<property name="paths.config" value="config" /> 
<property name="paths.config.file" value="${paths.config}/environment.ini" /> 

<available file="${paths.config.file}" property="configured" /> 

<target name="configure"> 
    <if> 
    <equals arg1="${configured}" arg2="true" /> 
    <then> 
     <echo message="Reconfigure ..." /> 
    </then> 
    <else> 
     <echo message="Configure ..." /> 
    </else> 
    </if> 

    <propertyprompt propertyName="db.host" defaultValue="localhost" promptText="Mysql Server Host" /> 
</target> 

<target name="skel"> 
    <echo msg="Skel files..." /> 

    <if> 
    <equals arg1="${configured}" arg2="${configured}" /> 
    <then> 
     <echo message="Missing config file ..." /> 
     <phingcall target="configure" /> 
    </then> 
    </if> 

    <echo message="${db.host}" /> 
    <copy todir="config"> 
     <mapper type="glob" from="*.skel" to="*"/> 
     <filterchain> 
      <expandproperties /> 
     </filterchain> 

     <fileset dir="config"> 
      <include name="*.skel" /> 
     </fileset> 
    </copy> 
</target> 

回答

6

我認爲phingcall將在內部創建一個新的環境。配置目標完成後,此環境超出範圍。

這意味着它是不可能的,因爲你的建議使用一個單獨的配置目標。

唯一的解決辦法可能是使配置目標創造所使用的其他目標的配置文件。

2

屬性的目標設定裏面的作用域到這些目標,並且不其父目標外部訪問。

the documentation for PropertyTask

約範圍重要提示:<property>標籤被稱爲<phingcall>標籤內,任何屬性都在一個新的局部範圍內設置。因此,該範圍內設置任何屬性或其他變量將不復存在(或恢復到以前的值)一旦父<phingcall>標籤完成。