iniファイルを解析して、antスクリプトで使用できるプロパティにしようとしています。私は次のものを持っています:
<project name="DeployScript" default="deploy-staging" basedir=".">
    <taskdef resource="net/sf/antcontrib/antcontrib.properties" />
    <!-- The location of the settings.ini file -->
    <property name="ini-file" location="../settings.ini" />
    <loadfile property="iniConfig" srcFile="${ini-file}"/>  
    <target name="deploy-staging" 
        description="Deploy project to staging environment" >
        <echo message="Ini file: ${ini-file}" />
        <echo message="${lib}" />
        <echo message="${store_dir}" />
        <echo message="${ant.home}" />
        <!--- walk the ini file's lines -->
        <foreach list="${iniConfig}"
            target="echoMsg"
            param="line" 
            delimiter="${line.separator}" />
        <echo message="HERE: ${prevSection}" />
    </target>
    <property name="prevSection" value="" />
    <!-- this is executed for every line in the ini file. -->
    <target name="echoMsg">  
        <!-- strip out the section name, variable name and value (if exists on the line) -->
        <propertyregex property="secm"
            input="${line}"
            regexp="^\[(.*)\]"
            select="\1"
            casesensitive="false" />
        <propertyregex property="name"
            input="${line}"
            regexp="^([\S]+)\s*=\s*([^;]+)"
            select="\1"
            casesensitive="false"
            defaultValue="" /> 
        <propertyregex property="value"
            input="${line}"
            regexp="^([\S]+)\s*=\s*([^;]+)"
            select="\2"
            casesensitive="false"
            defaultValue="" />
        <!-- overwrite the previous section if we have found a new one. -->
        <if>
            <isset property="secm" />
            <then>
                <echo message="PREVSECTION IS SET" />   
                <property name="prevSection" value="${secm}" />
            </then>
        </if>
        <!-- display the information about the found data -->       
        <echo message="line    = ${line}" />
        <echo message="section = ${secm}" />
        <echo message="name    = ${name}" />        
        <echo message="value   = ${value}" />
        <echo message="new last section: ${prevSection}" />
        <echo message="----" />             
    </target>   
</project>
私がやろうとしているのは、すべてのname = valueのペアを解析し、それらを次のようなプロパティに配置することです。section.name = value;
どういうわけか、セクションは「echoMsg」ターゲット内に記憶されていません。セクション名を覚えておいてほしい。
それで、
[global]
name=var
name2=val
[section2]
name=var
次のようになります。
global.name=var
global.name2=val
section2.name=var
これは私のantスクリプトの出力です:
echoMsg:
 [echo] PREVSECTION IS SET
 [echo] line    = [global]
 [echo] section = global
 [echo] name    =
 [echo] value   =
 [echo] new last section: global
 [echo] ----
echoMsg:
 [echo] line    = servername = my-server.local ; Server name
 [echo] section = ${secm}
 [echo] name    = servername
 [echo] value   = mac-mini-van-Peter.local7
 [echo] new last section: ${prevSection}
 [echo] ----
ご覧のとおり、最後の「${prevSection}」は設定されていません。私はそれが「グローバル」であることを期待します。
プロパティの代わりに使用しようとしましたが、違いはありません。