2013-02-13 71 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