FooTask.java:
/*
* Created on 2004-4-17
*
*/
import org.apache.tools.ant.Task;
/**
* FooTask.java
* <p>Copyright: Copyright (c) 2003 你可以对本程序随意修改,复制,使用,但请保留这里注释声明!!!</p>
* @author 李尚强 blundblade@sina.com
*/
public class FooTask extends Task {
private String name = "";
/**
* @return
*/
public String getName() {
return name;
}
/**
* @param string
*/
public void setName(String string) {
name = string;
}
public String toString() {
return name;
}
}
build.xml:
<?xml version="1.0" ?>
<project name="testTimer" default="test" basedir=".">
<taskdef name="timer" classname="TimerTask" classpath="."/>
<taskdef name="foo" classname="FooTask" classpath="."/>
<target name="test">
<timer action="init">
<foo name="F1" />
<foo name="F2" />
<foo name="F3" />
<foo name="F4" />
</timer>
<!-- You can do some long-time work here -->
<timer action="print" />
<echo message="You have use time :${timer.passed}" />
</target>
</project>