1
我正在嘗試爲Apache Ant編寫一個自定義任務(以下爲this tutorial)。自定義Ant任務中的「沒有兼容的構造函數」?
目前,我的任務是這樣的:
package my.package;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
class MyTask extends Task
{
private String command;
public void setCommand(String command)
{
this.command = command;
}
public void execute() throws BuildException
{
System.out.println(command);
}
}
我使用任務在我的構建文件如下:
<?xml version="1.0"?>
<project name="TaskExample" default="main" basedir=".">
<taskdef name="mytask" classname="my.package.MyTask"/>
<target name="main">
<mytask command="foobar" />
</target>
</project>
當調用Ant的,我得到以下錯誤:
> ant -lib .
Buildfile: /path/to/build.xml
main:
BUILD FAILED
/path/to/build.xml:6: Could not create type mytask as the class class my.package.MyTask has no compatible constructor
Total time: 0 seconds