0
我在这里指样本:https://ant.apache.org/manual/tutorial-tasks-filesets-properties.html蚂蚁:蚂蚁如何找到属性setter方法属性
import org.apache.tools.ant.BuildException;
public class Find extends Task {
private String property;
private String value;
private String print;
public void setProperty(String property) {
this.property = property;
}
// setter for value and print
public void execute() {
if (print != null) {
String propValue = getProject().getProperty(print);
log(propValue);
} else {
if (property == null) throw new BuildException("property not set");
if (value == null) throw new BuildException("value not set");
getProject().setNewProperty(property, value);
}
}
}
样品延伸的Ant任务建立一个自定义的任务。给出的蚂蚁任务脚本
<find property="test" value="test-value"/>
<find print="test"/>
该脚本正在设置几个属性“属性”和“打印”的值。我的问题是,Ant如何确定它必须调用“setProperty”方法来设置“property”属性的值?基本上,Ant如何确定类需要调用哪个方法?
谢谢你这么多。我在想同样的事情,但需要专家的建议 – Shashi