<propertyregex property="java.temppkg.dir" input="${base.package.path}/${lower.model.name}" regexp="\." replace="\/" >
</propertyregex>
<echo>${java.temppkg.dir}</echo>
如上面的ant代码,这段代码预计的作用是将input中的路径中带有"."的地方都替换成"/",然后将转换后的值赋给java.temppkg.dir.
实际的情况是,当input里有“.”的时候,java.temppkg.dir可以正常打印出值,而当input不带有"."的时候,echo语句打印不出值。
查看ant的api,可以得知,
Attribute
Description
Required
property |
The name of the property to set. |
Yes. |
override |
If the property is already set, should we change it's value. Can be true or false
|
No. Defaults to false
|
input |
The input string to be processed |
Yes. |
regexp |
The regular expression which is matched in the input string. |
Yes (can be specified in a<regexp> subelement). |
select |
A pattern which indicates what selection pattern you want in the returned value. This uses the substitution pattern syntax to indicate where to insert groupings created as a result of the regular expression match. |
Yes, unless a replace is specified |
replace |
A regular expression substitition pattern, which will be used to replace the given regular expression in the input string. |
Yes, unless a select is specified |
casesensitive |
Should the match be case sensitive |
No. default is "true". |
global |
Should a replacement operation be performed on the entire string, rather than just the first occurance |
No. default is false . |
defaultValue |
The value to set the output property to, if the input string does not match the specific regular expression. |
No.
|
可以注意到,propertyregex有一个defaultValue的属性,这个属性的作用是,当没有匹配到要替换的值时,方法返回的默认值是
什么。那么就是说,如果没有这个默认值,当匹配不到需要替换的值时,propertyregex实际上不返回任何东西。因此,
上面的方法在Input没有"."将不会返回任何东西。这不符合java的思想,可能是因为propertyregex本身并不是为了字符替换而产生的。
综上,将代码修改为下面的样子就可以正常得到结果:
<propertyregex property="java.temppkg.dir" input="${base.package.path}/${lower.model.name}" regexp="\." replace="\/" defaultvalue="${base.package.path}/${lower.model.name}">
</propertyregex>
<echo>${java.temppkg.dir}</echo>
分享到:
相关推荐
标题中的“ANT构建的一个问题”指的是在使用Apache Ant工具进行软件构建时遇到的特定问题。Apache Ant是一个Java库和命令行工具,其任务是驱动构建过程。它通过XML定义的构建文件来描述构建步骤,使得开发者可以自动...
"Ant ant ant antant ant ant antant ant ant ant" 这个描述可能是在强调Ant在项目构建过程中的重复性和不可或缺性,暗示着它在工程中的频繁使用和核心地位。 Ant的设计理念是“一切都是XML”,它通过XML格式的构建...
标签中的"ant_1", "ant_1.6", "ant_1.6.0", "ant-1.6.0"和"apache-ant-1.6"都指的是Apache Ant的不同版本,1.6.0是其中的一个稳定版本,发布于2003年,提供了许多改进和新特性,比如支持JUnit 3.8,对ivy依赖管理...
Apache Ant 是一个开源的构建工具,广泛用于Java项目构建,由Apache软件基金会开发。这个"apache-ant-1.6.5-bin.zip"文件是Ant的1.6.5版本的二进制发行版,适合在Windows操作系统上使用。Ant是基于Java的,它的主要...
在IT行业中,Ant是一个至关重要的自动化构建工具,尤其在Java开发领域中被广泛使用。Ant以其XML为基础的构建文件(通常命名为build.xml)为特点,允许开发者定义和执行项目的构建任务。现在,让我们深入探讨一下标题...
org.apache.tools.ant.Main org.apache.tools.ant.Task org.apache.tools.bzip2.CRC org.apache.tools.ant.Target org.apache.tools.ant.Project org.apache.tools.zip.ZipFile org.apache.tools.zip.ZipLong ...
开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6...
ant ant下载 ant配置ant ant下载 ant配置ant ant下载 ant配置
December 19, 2006 - Ant 1.7.0 Available Apache Ant 1.7.0 is now available for download. Ant 1.7 introduces a resource framework. Some of the core ant tasks such as <copy/> are now able to ...
Use the links below to download a source distribution of Ant from one of our mirrors. It is good practice to verify the integrity of the distribution files, especially if you are using one of our ...
Ant采用XML格式的配置文件,不仅避免了Makefile中常见的Tab问题,还提供了更为清晰的结构和易于维护的特性。Ant的构建过程主要围绕“Project”、“Target”和“Task”三个核心概念展开: - **Project**:代表整个...
这意味着设计库是经过官方验证的,质量可靠,并且与较新版本的Axure兼容,用户无需担心版本兼容性问题。同时,这个库被描述为"ui原型设计师不二之选",表明其在原型设计领域有着很高的评价和实用性。 "library.ant....
除了`<foreach>`,Ant Contrib还提供了其他有用的任务,如`if`、`unless`(条件语句)、`for`(更灵活的循环)、`propertyregex`(正则表达式处理属性)等。这些任务极大地增强了Ant脚本的表达能力,使其能更好地...
标题中的"ant1.9包下载"指的是Apache Ant 1.9系列的版本,这是该工具的一个重要里程碑,提供了许多增强的功能和修复了已知问题。 Ant的设计理念是通过XML来描述构建过程,使得构建脚本具有良好的可读性和可维护性。...
Ant是Apache软件基金会的一个开放源代码项目,是一个Java构建工具,它使得构建、部署和管理Java项目变得更加简单。Ant以其XML格式的构建文件而闻名,这些文件定义了构建过程中的任务序列,允许开发者以声明性的方式...
Apache Ant 是一个开源的构建工具,广泛用于Java项目管理,它是Apache软件基金会的产品之一。Ant以其XML为基础的构建文件(build.xml)而著名,这种文件定义了构建过程中的任务序列,使得开发人员能够自动化编译、...
ant配置后提示不是内部命令也不是外部命令解决办法: 1、解压缩包。例如解压到E:\学习类\apache-ant-1.8.2, 2、配置环境变量。在系统环境变量中新建一个ANT_HOME 的变量,值为D:\apache-ant-1.10.1。在path 变量中...
Axure AntDesign元件库是一款专为Axure设计的高质量组件集合,它旨在帮助原型设计师快速构建基于AntDesign设计系统的Web应用界面。AntDesign是阿里巴巴开源的一款著名前端UI框架,以其优雅、直观、高效的特性广受...
ANT+协议是一种无线通信协议,主要用于运动健康和健身设备之间的数据传输。该协议由Garmin公司开发,并在开放源码的基础上推广,使得不同厂商的设备能够无缝共享数据,如心率、速度、距离等运动参数。VS2015源文件指...
9. **最佳实践**:通过示例,你可以学习到Ant Design在实际项目中的最佳实践,如何避免常见问题,以及如何与其他库或服务集成。 压缩包内的两个文件"ant-design-demo1.rar"和"ant-design-demo2.rar"可能是不同版本...