2016-09-20 23 views
0

我對螞蟻任務很陌生,迄今爲止我設法通過一些參數調用一個exec,現在我試圖從META-IF/MANIFEST.MF文件中讀取一個版本來調用一個執行此文件的Implementation-Version屬性作爲arg(這意味着爲我的項目創建一個版本化的設置)。 到目前爲止,我只能找到如何替換屬性或如何從jar文件中讀取數據,但從來沒有從MANIFEST.MF文件中讀取屬性,並在隨後的任務中使用read屬性作爲var! 感謝提前:)Ant任務:讀取和用戶清單實施版本

+0

您可以參考這個問題的答案:http://stackoverflow.com/q/5313438 –

回答

1

可以使用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> 
+0

作品完全符合我的需求,謝謝! – n0xew