[英]Changing property value in Ant
I don't want to use propertyregex in the AntContrib task, but I need to modify a property. 我不想在AntContrib任务中使用propertyregex,但是我需要修改属性。 I am using the
cabarc
command (I can't get the <cab>
task to work), and I need to strip out the drive name. 我正在使用
cabarc
命令(我无法使<cab>
任务正常工作),并且我需要删除驱动器名称。
${basedir} = "D:\some\directory\blah\blah"
${cwd} = some\directory\blah\blah"
I need this in order to strip out the path in cabarc (but still using directories). 我需要这样做,以去除Cabarc中的路径(但仍使用目录)。 I've ended up doing the following:
我结束了以下工作:
<!-- Create a property set with just basedir -->
<!-- Needed for loadproperties to work -->
<propertyset id="cwd">
<propertyref name="basedir"/>
</propertyset>
<loadproperties>
<propertyset refid="cwd"/>
<filterchain>
<tokenfilter>
<replaceregex pattern=".:\\"
replace="cwd="/>
</tokenfilter>
</filterchain>
</loadproperties>
That works, but it's a little complex and will be hard to maintain. 可以,但是有点复杂并且很难维护。
Is there an easier way to do this? 有没有更简单的方法可以做到这一点?
get into the groove ;-) 进入凹槽;-)
<groovy>
properties.'cwd' = properties.'basedir'[3..-1]
</groovy>
or with Ant Plugin Flaka : 或使用Ant插件Flaka :
<project xmlns:fl="antlib:it.haefelinger.flaka" name="World">
<!-- simple echo -->
<fl:echo>#{replace('${basedir}', '$1' , '.:\\\\(.+)' )}</fl:echo>
<!-- set property -->
<fl:let>cwd := replace('${basedir}', '$1' , '.:\\\\(.+)' )</fl:let>
</project>
Disclosure = i'm participating as committer in the Flaka project 披露=我作为Flaka项目的提交者参加
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.