蚂蚁过滤 - 失败,如果物业没有设置 [英] ant filtering - fail if property not set

查看:115
本文介绍了蚂蚁过滤 - 失败,如果物业没有设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个蚂蚁使用&LT 的build.xml ;复制> 任务来复制各种XML文件。它采用过滤从 build.properties 文件的属性合并。每个环境(DEV,分期,督促)具有不同的 build.properties ,对于该环境中存储配置。

I've got a ant build.xml that uses the <copy> task to copy a variety of xml files. It uses filtering to merge in properties from a build.properties file. Each environment (dev, stage, prod) has a different build.properties that stores configuration for that environment.

有时我们会增加新的属性,在Spring的XML或其他配置文件,需要更新 build.properties 文件。

Sometimes we add new properties to the Spring XML or other config files that requires updating the build.properties file.

我想,如果有物业从 build.properties 失踪蚂蚁快速失败。也就是说,如果任何原 @ ...... @ 标记使之成为生成的文件,我想构建死让用户知道他们需要添加一个或多个属性当地build.properties。

I want ant to fail fast if there are properties missing from build.properties. That is, if any raw @...@ tokens make it into the generated files, I want the build to die so that the user knows they need to add one or more properties to their local build.properties.

这可能与内置的任务是什么?我找不到在任何文档。我要写一个定制Ant任务,但也许我可以放过自己的努力。

Is this possible with the built in tasks? I couldn't find anything in the docs. I'm about to write a custom ant task, but maybe I can spare myself the effort.

感谢

推荐答案

您可以做到这一点的蚂蚁1.7,使用的LoadFile 任务的组合和匹配的条件。

You can do it in ant 1.7, using a combination of the LoadFile task and the match condition.

<loadfile property="all-build-properties" srcFile="build.properties"/>
<condition property="missing-properties">
    <matches pattern="@[^@]*@" string="${all-build-properties}"/>
</condition>
<fail message="Some properties not set!" if="missing-properties"/>

这篇关于蚂蚁过滤 - 失败,如果物业没有设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆