How to over-write the property in Ant?

2019-01-14 06:12发布

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

8条回答
我想做一个坏孩纸
2楼-- · 2019-01-14 06:46

ant-contrib's Variable task can do this:

<property name="x" value="6"/>
<echo>${x}</echo>   <!-- will print 6 -->
<var name="x" unset="true"/>
<property name="x" value="12"/>
<echo>${x}</echo>   <!-- will print 12 -->

Not recommended, though, it can lead to weird side-effects if parts of your Ant scripts assume immutable property values, and other parts break this assumption.

查看更多
来,给爷笑一个
3楼-- · 2019-01-14 06:49

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>
查看更多
登录 后发表回答