* Attributes can be customized in ant, such<PropertyName= "Var1"Value= "Value1"/>;
* You can also use the java system attributes, such:
Java. runtime. Name = Java (TM) 2 Runtime Environment, Standard Edition
Sun. boot. Library. Path = C:/j2sdk1.4.2 _ 09/JRE/bin
Java. VM. Version = 1.4.2 _ 09-b05
Java. VM. Vendor = Sun Microsystems Inc.
Java. venduo. url = http://java.sun.com/
Path. Separator =;
Java. VM. Name = Java hotspot (TM) Client VM
File. encoding. PKG = sun. Io
User. Country = Cn
Sun. OS. Patch. Level = Service Pack 2
Java. VM. Specification. Name = Java virtual machine specification
User. dir = E:/Eclipse/testdemo
Java. runtime. Version = 1.4.2 _ 09-b05
Java. AWT. graphicsenv = sun. AWT. win32graphicsenvironment
Java. endorsed. dirs = C:/j2sdk1.4.2 _ 09/JRE/lib/endorsed
OS. Arch = x86
Java. Io. tmpdir = C:/docume ~ 1/admini ~ 1/locals ~ 1/temp/
Line. Separator =
Java. VM. Specification. Vendor = Sun Microsystems Inc.
User. Variant =
OS. Name = Windows XP
Sun. java2d. fontpath =
Java. library. path = C:/j2sdk1.4.2 _ 09/bin ;.; c:/Windows/system32; C:/windows; C:/j2sdk1.4.2 _ 09/bin; D:/Oracle/ora92/bin; C: /program files/Oracle/JRE/1.1.8/bin; C:/Windows/system32; C:/windows; C:/Windows/system32/WBEM; D: /MySQL Server 4.1/bin; D:/program files/IDM computer solutions/UltraEdit-32
Java. Specification. Name = Java platform API Specification
Java. Class. Version = 48.0
Java. util. prefs. preferencesfactory = java. util. prefs. windowspreferencesfactory
OS. Version = 5.1
User. Home = C:/Documents ents and settings/Administrator
User. timezone =
Java. AWT. printerjob = sun. AWT. Windows. wprinterjob
File. Encoding = GBK
Java. Specification. Version = 1.4
Java. class. path = E:/Eclipse/testdemo/bin; E:/Eclipse/lucene-1.4.3/lucene-2.0.0/Lucene-2.0.0/lucene-core-2.0.0.jar; E:/library/commons/commons-io-1.1.jar; E: /library/commons/commons-net-1.1.0.jar; F:/everyday/June/15/Je-analysis-1 [1]. 2.2.jar; E:/library/JUnit. jar
User. Name = CrAl
Java. VM. Specification. Version = 1.0
Java. Home = C:/j2sdk1.4.2 _ 09/JRE
Sun. Arch. Data. Model = 32
User. Language = ZH
Java. Specification. Vendor = Sun Microsystems Inc.
AWT. Toolkit = sun. AWT. Windows. wtoolkit
Java.vm.info = Mixed Mode
Java. Version = 1.4.2 _ 09
Java. Ext. dirs = C:/j2sdk1.4.2 _ 09/JRE/lib/EXT
Sun. boot. class. path = C:/j2sdk1.4.2 _ 09/JRE/lib/RT. jar; C:/j2sdk1.4.2 _ 09/JRE/lib/i18n. jar; C:/j2sdk1.4.2 _ 09/JRE/lib/sunrsasign. jar; C:/j2sdk1.4.2 _ 09/JRE/lib/JSSE. jar; C:/j2sdk1.4.2 _ 09/JRE/lib/JCE. jar; C:/j2sdk1.4.2 _ 09/JRE/lib/charsets. jar; C:/j2sdk1.4.2 _ 09/JRE/classes
Java. Vendor = Sun Microsystems Inc.
File. Separator =/
Java. Vendor. url. Bug = http://java.sun.com/cgi-bin/bugreport.cgi
Sun. Io. Unicode. Encoding = unicodelittle
Sun. CPU. endian = little
Sun. CPU. isalist = Pentium istmi386
* You can also use ant's built-in attributes, such:
The absolute path of the basedir project base Directory (same as the basedir attribute of <project> ).
The absolute path of ant. File buildfile.
Ant. Version ant version.
The name of the project currently executed by Ant. Project. Name is set by the name attribute of <project>.
The JVM Version Detected by Ant. java. Version ant. The current value is "1.1", "1.2", "1.3" and "1.4 ".
;
1. Use-DVAR = value to specify or modify the property value at runtime.
<? XML version = "1.0" encoding = "UTF-8" ?>
< Project Basedir = "." Default = "Test" Name = "Testproject" >
< Property Name = "Var1" Value = "Value1" />
< Property Name = "Var2" Value = "Value2" />
< Target Name = "Test" Description = "Test property overwrite" >
< Echo Message = "Var1 =$ {var1 }" />
< Echo Message = "Var2 =$ {var2 }" />
</ Target >
</ Project >
Run ant:
Test:
[Echo] var1 = value1
[Echo] var2 = value2
Run ant-dvar1 = value1new:
Test:
[Echo] var1 = value1new
[Echo] var2 = value2
Use System Environment Variables in 2ant
<Target name = "printinfo">
<Property environment = "env"/>
<Echo message = "$ {env. build_tag}"/>
</Target>
3
Complete!