2
是否有可能在Ant複製任務中複製當前文件名?我想運行一個腳本的BeanShell並希望訪問到當前文件名:在Ant複製任務過濾器中獲取文件名
<target>
<mkdir dir="${project.build.directory}/generated-sources"/>
<copy todir="${project.build.directory}/generated-sources"
includeemptydirs="true" failonerror="true" verbose="true">
<fileset dir="${project.build.sourceDirectory}"/>
<filterchain>
<tokenfilter>
<filetokenizer/>
<scriptfilter language="beanshell" byline="true"><![CDATA[
import java.io.BufferedReader;
import java.io.StringReader;
int count = 1;
BufferedReader br = new BufferedReader(new StringReader(self.getToken()));
StringBuilder builder = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
builder.append(line.replace("\"__LINE__\"", Integer.toString(count))).append('\n');
count++;
}
self.setToken(builder.toString());
]]></scriptfilter>
</tokenfilter>
</filterchain>
</copy>
</target>