ant的设置properties
特点
大小写敏感;
不可改变,先到先得,谁先设定,之后的都不能改变。
怎样设置
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.blogjava.net/wiflish/build.properties"/>, 导入http://www.blogjava.net/wiflish/build.properties 属性文件中的属性值。
7 、设置环境变量,比如: <property environment="env"/> ,设置系统的环境变量为前缀 env.
<property name="tomcat.home" value="${env.CATALINA_HOME}"/> 将系统的 tomcat 安装目录设置到 tomcat.home 属性中。
内置属性
Ant’s built-in properties:
basedir |
The absolute path of the project’s basedir. |
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. |
ant.project.default-target |
The name of the currently executing project’s default target. |
ant.project.invoked-targets |
A comma separated list of the targets that have been specified on the command line when invoking the current. |
ant.java.version |
The JVM version Ant detected. |
ant.core.lib |
The absolute path of the ant.jar file. |
System properties
java.version |
Java Runtime Environment version |
java.vendor |
Java Runtime Environment vendor |
java.vendor.url |
Java vendor URL |
java.home |
Java installation directory |
java.vm.specification.version |
Java Virtual Machine specification version |
java.vm.specification.vendor |
Java Virtual Machine specification vendor |
java.vm.specification.name |
Java Virtual Machine specification name |
java.vm.version |
Java Virtual Machine implementation version |
java.vm.vendor |
Java Virtual Machine implementation vendor |
java.vm.name |
Java Virtual Machine implementation name |
java.specification.version |
Java Runtime Environment specification version |
java.specification.vendor |
Java Runtime Environment specification vendor |
java.specification.name |
Java Runtime Environment specification name |
java.class.version |
Java class format version number |
java.class.path |
Java class path |
java.library.path |
List of paths to search when loading libraries |
java.io.tmpdir |
Default temp file path |
java.compiler |
Name of JIT compiler to use |
java.ext.dirs |
Path of extension directory or directories |
os.name |
Operating system name |
os.arch |
Operating system architecture |
os.version |
Operating system version |
file.separator |
File separator ("/" on UNIX) |
path.separator |
Path separator (":" on UNIX) |
line.separator |
Line separator ("\n" on UNIX) |
user.name |
User's account name |
user.home |
User's home directory |
user.dir |
User's current working directory |
用法
${key_name},如:${os.name},它将得到当前操作系统的名称。
需注意
1. 内置属性basedir
-- 不需要定义就可以直接使用,${basedir},得到当前工程的绝对路径
-- 当在<project>标签的basedir属性中指定basedir时,之后工程中出现的所有相对路径都是相对于这个basedir所指向的路径,且${basedir}的值也将变为<project>标签中的basedir属性所指定的值。
2. property的不变性在使用<available><ant><antcall>时会被打破
3. 可以在命令行通过-DpropertyName=propertyValue的方式指定property,注意,-D于propertyName之间没有空格,使用这种方式指定的属性最先被赋值,它是在执行build文件之前就已经赋值了的。
Q&A
How can I do something like <property name="prop" value="${${anotherprop}}"/>
(double expanding the property)?
Without any external help you can not.
With <script/>, which needs external libraries, you can do
- <script language="javascript">
- propname = project.getProperty("anotherprop");
- project.setNewProperty("prop", propname);
- </script>
With AntContrib (external task library) you can do <propertycopy name="prop" from="${anotherprop}"/>
.
With Ant 1.6 you can simulate the AntContribs <propertycopy> and avoid the need of an external library:
- <macrodef name="propertycopy">
- <attribute name="name"/>
- <attribute name="from"/>
- <sequential>
- <property name="@{name}" value="${@{from}}"/>
- </sequential>
- </macrodef>
With the 'props' antlib (external, but also from Ant) you could do the dereferencing with ${${anotherprop}
- not just in the property task - instead everywhere in your buildfile (after registering the required property helper).
- <propertyhelper>
- <props:nested />
- </propertyhelper>
- <property name="foo" value="foo.value" />
- <property name="var" value="foo" />
- <echo> ${${var}} = foo.value </echo>
With Flaka (external Ant Plugin) you could do the dereferencing with #{${anotherprop}}
- not just in flaka tasks, but all tasks after installing flaka's property handler.
- <project xmlns:fl="antlib:it.haefelinger.flaka">
- <fl:install-property-handler/>
- <property name="foo" value="foo.value"/>
- <property name="var" value="foo" />
- <property name="buildtype" value="test"/>
- <property name="appserv_test" value="//testserver"/>
- <echo>
- #{${var}} = foo.value
- <!-- nested property -->
- #{appserv_${buildtype}}
- </echo>
- </project>
转载于:https://www.cnblogs.com/cl1024cl/p/6205635.html
ant的设置properties相关推荐
- 保存Java程序状态及设置Properties文件
保存Java程序状态及设置Properties文件 作者: 刻录机, 出处:中国IT实验室, 责任编辑: 包春林, 2008-04-11 00:00 使用Properties文件来保存.Propert ...
- Jenkins+jmeter+ant自动化设置jira面板统计图每日更新
1. 需求描述 领导提出了一个需求:每天可以看到仪表盘中,关于项目A的每日bug统计情况 2. 思路设计 2.1 初步思路 1)根据创建时间,设置当日进行查询,然后保存为筛选器名称:当日数据统计 2) ...
- ant design 设置网页的title
ant design 的页面都是用js编写,如何在页面标签页或者在接入微信的页面中,最上面显示网页名称,在ant design文件中直接使用, document.title = '标题名称'; 即可在 ...
- ant vue 设置中文_Ant Design Vue 添加区分中英文的长度校验功能
原本的maxLength属性是不区分全角/半角字符的,对于一些可中英文混合输入地方而言不太合适.所以想找一个可区分全角/半角字符的校验,而且要保证一定的可重用性. 百度搜了一圈都没找到合适的现成的解决 ...
- ant vue 设置中文_vue+Ant design vue做项目-Go语言中文社区
哈喽哈喽,这期带来蚂蚁金服的一个 Ant Design 的 Vue 实现. 样式还是很现代化的,嗯...现在是2019年9月17,对现在来说还很fashion过几年就不知道了. 话不多说直接上手,喜欢 ...
- springboot读取腾讯企业邮箱的时候怎么设置Properties
1.请看代码,使用pop3去读取 // 准备连接服务器的会话信息Properties props = new Properties();props.setProperty("mail.sto ...
- React开发(173):ant design设置额外的展开行
expandedRowRender 额外的展开行 Function(record, index, indent, expanded):ReactNode
- 在Eclipse中集成Ant编程之配置篇
提要:本文将向你展示如何使用Eclipse设置为Ant所用的属性值和环境变量,并简要分析如何配置Ant编辑器以便从Eclipse内部操作Ant文件. 一. 修改Ant Classpath 在使用一个可 ...
- Java Ant 学习总结
Java_Ant详解 http://www.cnblogs.com/huozhicheng/archive/2010/04/08/2533199.html 1,什么是ant ant是构建工具 2,什么 ...
最新文章
- 苹果公司华人研究员抛弃注意力机制,史上最快的Transformer!新模型达成最低时间复杂度...
- 机器学习实践:TensorFlow2 多GPU负载不均衡问题
- 解决rspec 生成报告时报utf-8错误的方法
- 微信公众平台“自定义回复”技巧
- linux(windows)之svn重定向地址
- 这个故事告诉你,拥有吃不胖的超能力就无忧无虑
- Sublime中查找重复行的正则表达式
- python中迭代器和可迭代对象的区别_Python 可迭代对象迭代器生成器的区别
- jsf集成spring_Spring JSF集成
- ../bin/testCurveFitting 出现的错误以及解决办法
- 用计算机算微积分,AP微积分AB BC 计算器使用要求
- 详解MATLAB之freqz()函数
- 基于springboot的网上零食购物系统
- java decompiler 乱码_jd-gui-1.6.6 乱码问题整理(about jd-gui-1.6.6 garbled code.)
- python,执行pip报错:Fatal error in launcher: Unable to create process using ‘“D:\tools\python.exe“ (已解决)
- u盘服务器安装win7系统,服务器u盘安装win7系统
- 大白菜U盘制作工具V3.0教程
- Character类
- cocos2d-x : csb的加载
- 笔记本计算机无法启动怎么解决,笔记本开机进不了系统,教您笔记本开机无法进入系统怎么办...
热门文章
- django文档_如何在django官方文档中快速找到需要的内容
- 最长递增子序列Python解法
- hyperion高光谱参数_[ENVI] 珠海一号高光谱数据处理
- 最新虚拟机VMware 下载安装
- 最大功率点跟踪测试软件,最大功率点跟踪
- oracle11g系统初始化意义,Oracle11G 初始化脚本
- % mysql 代表_MySQL中的星号(*)和百分号(%)代表表示什么,MySQL的库名、表名、字段名、字段值是否区分大...
- hdfs中与file数组类似的数组_Chapter05 Java中的数组
- vue 监听map数组变化_vuex state中的数组变化监听实例
- 别再叫我“老工”!!!工程师姓什么很重要!