我有我的主 build.xml,它从共享目录导入 common-build.xml。 common-build.xml 导入位于同一目录中的 build.properties。目前我必须使用 common.dir 属性,该属性是通过调用 build.xml 设置的。如果我这样做
<property file="build.properties"/>
然后它加载相对于 build.xml 所在的“根”目录的 build.properties。
我可以从 common-build.xml 而不是 build.xml 进行 build.properties 的相对加载吗?
最佳答案
您可以使用相对路径来引用属性文件的位置。
另一个相关技术是使用 ant 的 dirname 任务。
<project name="project tests" default="runtests" basedir=".">
<dirname property="some.basedir" file="${ant.file.project tests}"/>
属性“some.basedir”现在指的是 build.xml 文件的目录。
最后,您始终可以在命令行上传递一个属性文件。
ant -propertyfile 文件路径
关于java - 在 Ant 中,如何导入与声明构建文件相关的属性文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3657829/