tags:

views:

35

answers:

1

In the following phing xml, inside the "skel" target I check if the app is configured, if it's not then I call the configure target and then apply the config to several files.

The problem is that property db.host is not set after the phingcall, even though it is set after the propertyprompt.

What am I missing?

<!-- 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>
A: 

I think the phingcall will create a new environment internally. When the configure target is done, this environment is out of scope.

This means it is not possible to use a separate configure target as you are suggesting.

The only solution might be to make the configure target create a configuration file which is used by the other targets.

Tomas