简体   繁体   English

检查目标中的属性ant文件

[英]Check properties ant file in a target

I'm a novice in Java. 我是Java的新手。 In my Ant file, I would like to create a target "init" which checks if the properties declared exist (else it affects them a default value), but I don't have any idea how to do. 在我的Ant文件中,我想创建一个目标“ init”,它检查声明的属性是否存在(否则会影响它们的默认值),但是我不知道该怎么做。

It's easier than you'd think. 它比您想象的要容易。 Just set them in the init target. 只需将它们设置在init目标中即可。 In Ant, setting properties is "first setter wins" - if they are already set, the setting in the init target will be ignored. 在Ant中,设置属性是“第一个设置者获胜”-如果已经设置,则初始化目标中的设置将被忽略。

There are several ways to set properties, but the most commonly used is: 有几种设置属性的方法,但最常用的是:

<property name="foo" value="dist"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM