如何获取 ant 构建 xml 文件自己的名称?



假设我有一个名为build_dev_linux.xml的文件。

我的问题是

如何查找ant脚本XML文件自己的名称build_dev_linux.xml这样我就可以把它放在XML文件中的变量或属性上了。?

Ant定义了一个有用的内置属性列表:
basedir             the absolute path of the project's basedir (as set
                    with the basedir attribute of <project>).
ant.file            the absolute path of the buildfile.
ant.version         the version of Ant
ant.project.name    the name of the project that is currently executing;
                    it is set in the name attribute of <project>.
ant.project.default-target
                    the name of the currently executing project's
                    default target;  it is set via the default
                    attribute of <project>.
ant.project.invoked-targets
                    a comma separated list of the targets that have
                    been specified on the command line (the IDE,
                    an <ant> task ...) when invoking the current
                    project.
ant.java.version    the JVM version Ant detected; currently it can hold
                    the values "1.2", "1.3",
                    "1.4",  "1.5" and "1.6".
ant.core.lib        the absolute path of the ant.jar file.

ant.file属性正是您所需要的。如果你只想要没有路径的文件名,那么你可以像一样使用basename任务

<basename file="${ant.file}" property="buildfile"/>

最新更新