2009-11-19 64 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>标签完成。