2013-02-13 22 views
7

比方说,我有一个名为build_dev_linux.xml的文件。如何获取ant build xml文件的名称?

我的问题是

我如何才能找到Ant脚本的XML文件的自己的名字,build_dev_linux.xml 这样我就可以把它放在变量或属性在XML文件中。?

+0

为什么不能直接设置包含名称 – Shurmajee 2013-02-13 04:22:28

+0

属性为减少处理点 – 2013-05-20 12:59:56

回答

13

蚂蚁定义内置属性的一个有用的清单:

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

谢谢。我不知道从哪里开始,现在我想我有一个。:) – 2013-02-14 06:01:49