ant中如何获取不带扩展名的文件名

发布于 2024-12-14 06:39:34 字数 266 浏览 3 评论 0原文

我知道如何使用 java 的 ANT 构建工具获取文件的基本名称,但在本例中我想更改文件名以包含构建版本号。不幸的是,该文件的名称是在我导入的另一个 ant 脚本(来自 Android 系统)中设置的,并且我无法设置该文件的属性,或者导入的脚本会抱怨该属性不应已设置。因此,如果我有一个包含 MyApp-release.apk 的属性,并且我想将该值更改为 MyApp-release-1.10.apk,我该怎么做?我知道我可以将 1.10 放在带有基本名称的文件名的开头,这可能就是我会做的,但我宁愿以其他方式进行。

I know how to get the basename for a file with java's ANT build tool, but in this case I want to change the name of a file to include a build version number. Unfortunately the file's name gets set in another ant script (from the android system) which I am importing and I'm not able to set the property for that file or the imported script will complain that the property should not be set already. Thus, if i have a property holding MyApp-release.apk and I want to change the value to MyApp-release-1.10.apk how would I do this? I know I can put the 1.10 at the start of the filename with basename and that's probably what I will do, but I'd rather do it the other way.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

缘字诀 2024-12-21 06:39:34

表单 http://ant.apache.org/manual/Tasks/basename.html

确定指定文件的基本名称的任务,可以选择减去
指定后缀。

<basename property="cmdname" file="D:/usr/local/foo.exe"
          suffix=".exe"/>

Form http://ant.apache.org/manual/Tasks/basename.html:

Task to determine the basename of a specified file, optionally minus a
specified suffix.

<basename property="cmdname" file="D:/usr/local/foo.exe"
          suffix=".exe"/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文