You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何移除maven-antrun-plugin写入文件的版本末尾%符号?

解决maven-antrun-plugin写入文件末尾出现%的问题

首先明确:你看到的末尾%并非文件实际内容,而是zsh终端的提示符。原因是Ant的echo任务写入的版本号没有末尾换行符,导致cat输出后,shell提示符直接跟在内容行末尾,看起来像是文件里的字符。

以下两种方法可以解决:

  • 方法1:添加系统换行符
    修改maven-antrun-plugin的echo配置,在版本号后拼接Ant内置的${line.separator}变量,自动适配不同系统的换行格式:

    <echo file="log-ant-run.txt" append="false" message="${project.version}${line.separator}"/>
    
  • 方法2:使用echo的newline属性(Ant 1.8+)
    若你的Ant版本为1.8或更高,可直接给echo任务添加newline="true"属性,强制写入换行:

    <echo file="log-ant-run.txt" append="false" message="${project.version}" newline="true"/>
    

你可以用hexdump -C log-ant-run.txt查看文件十六进制内容,验证文件实际是否包含%符号,确认问题根源。

内容的提问来源于stack exchange,提问作者Hare Krshn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 14:18:09