全て -
私はこのページで最も簡単な指示に従っています:
http://ant.apache.org/manual/develop.html
ただし、ターゲット「main」を実行しようとすると、netbeansで次のエラーが発生します。
taskdef class dec102012.MyAntTask cannot be found using the classloader AntClassLoader[]
しかし、「Task」を拡張する新しいJavaクラスは次のようになっているため、このエラーは意味がありません。
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>