2013-02-13 5 views
7

diciamo che ho un file chiamato build_dev_linux.xml.Come ottenere il nome proprio del file xml di ant form?

La mia domanda è

Come posso trovare proprio il nome del file XML script ant, build_dev_linux.xml così posso mettere su variabili o proprietà in quel file XML.?

+0

Perché non puoi impostare direttamente una proprietà che contiene il nome – Shurmajee

+0

Per ridurre i punti di manipolazione –

risposta

13

Ant definisce un utile elenco delle proprietà incorporato:

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. 

Il ant.file proprietà è quello che ti serve. Se si desidera solo il nome del file senza il percorso quindi è possibile utilizzare l'attività basename come

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

Grazie. Non sapevo da dove cominciare e ora penso di averne uno :) –

Problemi correlati