Macrodef and "local properties"

I am trying to move a file (specified by a template) to a given location in Ant macrodef:

<macrodef name="extract"> <attribute name="package"/> <sequential> <!-- the path will contain the unique file in extracted regardless of the name --> <path id="source_refid"> <dirset dir="${dep}/lib/@{package}/extracted/"> <include name="@{package}-*"/> </dirset> </path> <!-- this is not working: properties are immutable --> <property name="source_name" refid="source_refid"/> <move file="${source_name}" tofile="${dep}/@{package}/" overwrite="true" /> </sequential> </macrodef> 

This will only work once since ${source_name} is immutable.

The parameter would have to use the variable task, but I did not find a way to assign refid to var .

Is there a way to have something similar to a local variable in macrodex? Or (problem XY) is there a better way to solve my problem?

+6
source share
1 answer

Since Ant 1.8, you can use the local task . For instance:

 <local name="source_name"/> <property name="source_name" refid="source_refid"/> 

Your example is just a local thing for!

+8
source

Source: https://habr.com/ru/post/902519/


All Articles