- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
<macrodef name="foreach">
<attribute name="target"/>
<attribute name="file-property"/>
<element name="files"/>
<element name="args"/>
<sequential>
<local name="foreach.files"/>
<local name="foreach.target"/>
<local name="foreach.file-property"/>
<local name="foreach.args"/>
<property name="foreach.target" value="@{target}"/>
<property name="foreach.file-property" value="@{file-property}"/>
<pathconvert property="foreach.files">
<files/>
</pathconvert>
<propertyset id="foreach.args">
<args/>
</propertyset>
<property name="foreach.args" refid="foreach.args"/>
<property name="foreach.target" value="@{target}"/>
<!-- there is no better way to do this at the moment
property names and values should not contain comma-space and equals signs
-->
<script language="javascript"><![CDATA[
var files = project.getProperty("foreach.files").split(":"),
args = project.getProperty("foreach.args").split(", "),
task = project.createTask("antcall"), arg;
task.target = project.getProperty("foreach.target");
for (var a in args) {
arg = task.createParam();
arg.setName(a.split("=")[0]);
arg.setValue(String(a.split("=")[1]));
}
for (var f in files) {
arg = task.createParam();
arg.setName(project.getProperty("foreach.file-property"));
arg.setValue(String(files[f]));
task.perform();
}
]]></script>
</sequential>
</macrodef>
<!-- пример использования: -->
<target name="transcode-font-helper">
<property name="font.face.local" value="${font.face}"/>
<foreach target="transcode-font" file-property="font.raw.source">
<files>
<fileset dir="${basedir}/fonts">
<include name="*/${font.face.local}/*.otf"/>
<include name="*/${font.face.local}/*.ttf"/>
</fileset>
</files>
<args>
<propertyref name="font.face.local"/>
</args>
</foreach>
</target>