Ant:将路径转换为单独的属性
我有一个包含几个 jar 文件的文件夹,这些文件都应该转到类路径:
<path id="my.classpath">
<fileset dir="/tmp/mylibs" includes="*.jar" />
</path>
现在我希望能够将所有这些 jar 文件作为单独的属性引用, 例如,如果我有两个 jar 文件 foo.jar 和 bar.jar 那么我希望能够像
${foo.jar} (== /tmp/mylibs/foo.jar)
${bar.jar} (== /tmp/mylibs/bar.jar)
在 Ant 中那样引用它们吗?
谢谢,彼得
I have a folder containing several jar files which should all go to a classpath:
<path id="my.classpath">
<fileset dir="/tmp/mylibs" includes="*.jar" />
</path>
Now I would like to be able to reference all these jar files as a seperate property,
e.g. if I have two jar files foo.jar and bar.jar then I would like to be able to reference them like
${foo.jar} (== /tmp/mylibs/foo.jar)
${bar.jar} (== /tmp/mylibs/bar.jar)
Is that somehow possible in Ant?
Thanks, Peter
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 ant-contrib 的帮助下,您可以尝试以下操作:
对于覆盖属性值(如果需要)您还可以使用 ant-contrib
With help of ant-contrib you can try this:
For overriding property value (if you need) purpose you can also use ant-contrib
Ivy 有一个 artifactproperty 任务,旨在执行此操作为你。
该解决方案的唯一问题是它假设您使用 ivy 来解决依赖关系并管理类路径。
Ivy has a artifactproperty task which is designed to do this for you.
The only catch to this solution is that it assumes you're using ivy to resolve your dependencies and manage your classpath.
将整个类路径放入单个属性的简单方法:
我相信这将在 Eclipse .classpath 文件中工作。现在我面前没有人。如果您必须操作它,您可以通过过滤器链的
任务来完成。An easy way to get the entire classpath into a single property:
I believe this will work in an Eclipse .classpath file. I don't have one in front of me right now. If you have to manipulate it, you can do that via the
<concat>
task with the filterchains.