ANT property三种使用方式

来源:互联网 发布:java调用内部类的方法 编辑:程序博客网 时间:2024/05/21 11:33

方式一:引入*.properties文件

1.在cms.properties文件中定义属性

userName=admin

2.在build.xml中引入属性

<property file="${basedir}/build/cms.properties"></property>

3.使用*.properties文件中的属性

<echo message="userName:${userName}"/>

方式二:build文件定义

1.定义properties

<property name="email" value="788999@qq.com"></property>

2.使用properties

<echo message="email:${email}"/>

方式三:ant执行参数传递

1.执行时传入参数

D:\projects\cms\build>ant -Dmobile=18300506123

参数名称:mobile     参数值:18300506123

2.使用properties

<echo message="mobile:${mobile}"/>


具体演示:

1.定义属性文件*.properties


2.编写build.xml


3.执行ant



0 0
原创粉丝点击