【问题标题】:How to get the ant build xml file's own name?如何获取ant build xml文件自己的名字?
【发布时间】:2013-02-13 04:14:27
【问题描述】:

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

我的问题是

如何找到 ant 脚本 XML 文件自己的名称,build_dev_linux.xml 所以我可以把它放在那个 XML 文件中的变量或属性上。?

【问题讨论】:

  • 为什么不能直接设置包含名字的属性
  • 减少搬运点

标签: ant filenames


【解决方案1】:

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"/>

【讨论】:

猜你喜欢
  • 2011-06-15
  • 2023-03-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-10-20
  • 2019-08-16
  • 1970-01-01
相关资源
最近更新 更多