首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

ant property 小结

2012-11-01 
ant property 总结详见:http://ant.apache.org/manual/index.html1.特点 大小写敏感; 不可改变,先到先得,

ant property 总结

详见:http://ant.apache.org/manual/index.html

1.特点

大小写敏感;

不可改变,先到先得,谁先设定,之后的都不能改变。

如下的build.xml

?

?

?执行后控制台的打印信息如下所示:

?

Note also that properties are case-sensitive, even if the environment variables on your operating system are not; e.g. Windows 2000's system path variable is set to an Ant property named "env.Path" rather than "env.PATH".classpaththe classpath to use when looking up a resource.Noclasspathrefthe classpath to use when looking up a resource, given as?reference?to a?<path>?defined elsewhere..NoprefixPrefix to apply to properties loaded using?file,?resource, or?url. A "." is appended to the prefix if not specified.NoprefixValuesWhether to apply the prefix when expanding the right hand side of properties loaded usingfile,?resource, or?url.?Since Ant 1.8.2No (default=false)relativeIf set to?true?the relative path to?basedir?is set.?Since Ant 1.8.0No (default=false)basedirThe basedir to calculate the relative path from.?Since Ant 1.8.0No (default=${basedir})

?

?

3. ? 7种设置方式

1)、设置name和value属性值,比如:<property name="srcdir" value="${basedir}/src"/>

2)、设置name和refid属性值,比如:<property name="srcpath" refid="dao.compile.classpath"/>,其中dao.compile.classpath在别的地方定义。

3)、设置name和location属性值,比如:<property name="srcdir" location="src"/>,即将srcdir的值设置为:当前项目根目录的/src目录。

4)、设置file属性值,比如:<property file="build.properties"/>, 导入build.properties属性文件中的属性值

5)、设置resource属性值,比如:<propety resource="build.properties"/>,导入build.properties属性文件中的属性值

6)、设置url属性值,比如:<property url="http://www.mysite.com/bla/props/foo.properties"/>,导入http://www.mysite.com/bla/props/foo.properties属性文件中的属性值。

7)、设置环境变量,比如:<property environment="env"/>,设置系统的环境变量为前缀env.

? ? ?<property name="tomcat.home" value="${env.CATALINA_HOME}"/> 将系统的tomcat安装目录设置到tomcat.home属性中。


4.内置属性

?如果这个时候还没有声明build.classes.dir,那么就会视为${build.classes.dir}

热点排行