2011-08-09 6 views
2

私は2つのプロパティを持っています.1つはファイルのリストで、もう1つはdirのリストです。このプロパティファイルを読み取ってAntファイルをコピーする

ファイル= FILE1、FILE2、FILE3、FILE4

destination.dir = DIR1、DIR2、DIR3、DIR4

ように、これらの2つのプロパティは、build.propertiesに定義されています。

file1をdir1に、file2をdir2にコピーしたいと思います。

これをどのようにして蟻で達成できますか?

おかげ

答えて

1

AntのアドオンとソリューションFlaka

<project xmlns:fl="antlib:it.haefelinger.flaka"> 
<!-- make standard ant tasks like copy understand EL expressions --> 
<fl:install-property-handler /> 

<property name="files" value="/some/path/file1,/some/path/file2,/some/path/file3,/some/path/file4"/> 
<property name="destination.dir" value="/some/otherpath/dir1,/some/otherpath/dir2,/some/otherpath/dir3,/some/otherpath/dir4"/> 

<!-- iterate over the csv property destination.dir --> 
<fl:for var="dir" in="split('${destination.dir}', ',')"> 
    <!-- copy the first item from csv property ${files} --> 
    <copy file="#{split('${files}',',')[0]}" todir="#{dir}" verbose="true"/> 
    <!-- 
    afterwards delete this file item from csv property ${files}, means 
    editing and overwriting ${files} for the next loop 
    --> 
    <fl:let>files ::= replace('${files}', '' , '#{split('${files}',',')[0]},?')</fl:let> 
</fl:for> 

</project> 

は、代わりにスクリプトタスク

内グルーヴィー、BeanShellの、(J)ルビー、JavaScriptの..として、いくつかのスクリプト言語を使用します
関連する問題