我对 ant 任务还很陌生,到目前为止,我已经成功地使用一些参数调用了 exec,现在我正在尝试从 META-IF/MANIFEST.MF
中读取版本> 文件来调用 exec,并使用该文件的 Implementation-Version
属性作为参数(这意味着为我的项目创建版本化设置)。
到目前为止,我只能找到如何替换属性或如何从 jar 文件中读取,但从未从 MANIFEST.MF 文件中找到并将读取的属性用作稍后在 ant 任务中的 var!
预先感谢:)
最佳答案
您可以使用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>
关于java - Ant 任务: read and user manifest implementation version,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39604915/