一些片段使用 Ant Addon Flaka迭代 csv 属性并在每次迭代时附加内容:
<project xmlns:fl="antlib:it.haefelinger.flaka">
<property name="foobar" value="Alpha,Beta,Gamma,Delta,Epsilon,Zeta,Eta,Theta,Iota,Kappa,Lambda"/>
<property name="foobaz" value="My,Ny,Xi,Omikron,Pi,Rho,Sigma,Tau,Ypsilon,Phi,Chi,Psi,Omega"/>
<fl:for var="item" in="split('${foobaz}', ',')">
<fl:let>foobar ::= concat('${foobar}',',#{item}')</fl:let>
</fl:for>
<echo>$${foobar} => ${foobar}</echo>
</project>
输出 :
[echo] ${foobaz} => Alpha,Beta,Gamma,Delta,Epsilon,Zeta,Eta,Theta,Iota,Kappa,Lambda,My,Ny,Xi,Omikron,Pi,Rho,Sigma,Tau,Ypsilon,Phi,Chi,Psi,Omega
编辑
很高兴你明白了,虽然我的片段有点愚蠢,因为一个人可以通过简单的方式实现一些结果
<property name=someproperty value=${foobar},${foobaz}>
不知道您的要求的详细信息,但这是一个改编的片段,
为您的 csv 属性的任何项目添加 /length 后缀:
<project xmlns:fl="antlib:it.haefelinger.flaka">
<property name="foobar" value="Alpha,Beta,Gamma,Delta"/>
<property name="foobaz" value=""/>
<fl:for var="item" in="split('${foobar}', ',')">
<fl:choose>
<!-- avoid a leading ',' -->
<fl:when test="'${foobaz}'.length eq 0">
<fl:let>foobaz ::= concat('${foobaz}','#{item}/length#{item.length}')</fl:let>
</fl:when>
<fl:otherwise>
<fl:let>foobaz ::= concat('${foobaz}',',#{item}/length#{item.length}')</fl:let>
</fl:otherwise>
</fl:choose>
</fl:for>
<!-- optionally overwrite ${foobar} with ${foobaz} -->
<fl:let>foobar ::= '${foobaz}'</fl:let>
<echo>$${foobar} => ${foobar}</echo>
</project>
输出 :
[echo] ${foobar} => Alpha/length5,Beta/length4,Gamma/length5,Delta/length5