如何将值从build.xml文件传递到java类?
我想在运行时将值从 build.xml 文件传递到 java 类。我们知道我们可以使用 ant 将值从命令行传递到 build.xml 文件。但是如何将此值从构建文件传递到 java 文件。我们可以用属性文件来完成,但是怎么做呢?
i want to pass the value from build.xml file to java class at run time. We know that we can pass value from command line with ant to the build.xml file. But how to pass this value from build file to java file. We can done it with property file but how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
PropertyFile
任务从 ant 操作属性文件。PropertyFile
task to manipulate a properties file from ant.假设您想从 build.xml 读取
,这里是纯 xml 读取/解析方法,您也可以使用 Project、ProjectHelper - 请参阅如何解析和解释 ant 的 build.xml
(如果需要)到从ant修改源代码,请参阅是否可以修改源代码与蚂蚁?
assume you want to read
<property name="version" value="123"/>
from build.xml, here is plain xml read/parse approachyou can also user Project, ProjectHelper - see How to parse and interpret ant's build.xml
if you want to modify source code from ant, see Is it possible to modify source code with ant?