可以使用loadfile任務,嵌套FilterChain S:
<loadfile property="implementation.version" srcFile="MANIFEST.MF">
<filterchain>
<!-- following filter tokenize input file and return only
the lines that match the pattern. Matched string is
replaced by an empty string to get only the value of the
manifest property.
-->
<tokenfilter>
<containsregex pattern="Implementation-Version:[ \t]*" replace="" flags="i"/>
</tokenfilter>
</filterchain>
</loadfile>
<!-- now 'implementation.version' contains the rest of the line that was matching the regex -->
<echo>Implementation version is ${implementation.version}</echo>
您可以參考這個問題的答案:http://stackoverflow.com/q/5313438 –