How to over-write the property in Ant?

后端 未结 8 1210
旧时难觅i
旧时难觅i 2020-12-05 13:21

Is there a way to re-assign the value for the Ant property task? Or is there another task available for that purpose?

相关标签:
8条回答
  • 2020-12-05 14:16

    Here is a sample using local with the basename command. Var-unset does not work for me.

    <for param="db-patches">
           <path>
                <fileset dir="${undeployed-files}" includes="**/ddl*.zip"/>
            </path>
            <sequential>
                  <local name="inpfile" />
                   <basename property="inpfile" file="@{db-patches}" suffix=".zip" />
                   <!-- unzip the patch  -->
                   <unzip src="${undeployed-files}/${inpfile}.zip" 
                       dest="${unzipped-patches}/${inpfile}" />
               <move file="${undeployed-files}/${inpfile}.zip" tofile="${deployed-files}/${inpfile}.zip"/>
            </sequential>   </for>
    
    0 讨论(0)
  • 2020-12-05 14:18

    Depending on how you want to use the modified property, you can use macrodefs.

    For example, instead of writing the following:

    <target name="foo">
       <echo message="${my_property}"/>
    </target>
    

    and not being able to call ant foo with another message, you could write:

    <macrodef name="myecho">
        <attribute name="msg"/>
        <sequential>
            <echo message="@{msg}"/>
        </sequential>
    </macrodef>
    
    <target name="foo">
       <myecho msg="${my_property}"/>
       <property name="my_property2" value="..."/>
       <myecho msg="${my_property2}"/>
    </target>
    
    0 讨论(0)
提交回复
热议问题