全部 -
我正在遵循这个页面上最简单的指导:
http://ant.apache.org/manual/develop.html
然而,当我尝试在NetBeans中执行目标“main”时,出现以下错误:
taskdef class dec102012.MyAntTask cannot be found using the classloader AntClassLoader[]
但是这个错误没有意义,因为我新建的Java类继承了“Task”,代码如下:package dec102012;
import org.apache.tools.ant.BuildException;
public class MyAntTask extends org.apache.tools.ant.Task{
private String msg;
// The method executing the task
public void execute() throws BuildException {
System.out.println(msg);
}
// The setter for the "message" attribute
public void setMessage(String msg) {
this.msg = msg;
}
}
我的build.xml文件中相关部分如下:
<taskdef name="mytask" classname="dec102012.MyAntTask" classpath="dec102012"/>
<target name="main">
<mytask message="Hello World! MyVeryOwnTask works!"/>
</target>
classpath="dec102012"
。 - Ismail Badawi