简体   繁体   English

找不到taskdef ant任务

[英]The taskdef ant task cannot be found

All - 全部 -

I'm following the most simplest instructions on this page: 我正在按照此页面上最简单的说明操作:

http://ant.apache.org/manual/develop.html http://ant.apache.org/manual/develop.html

However, when I try to execute the target "main" I get this error in netbeans: 但是,当我尝试执行目标“main”时,我在netbeans中遇到此错误:

 taskdef class dec102012.MyAntTask cannot be found using the classloader AntClassLoader[] 

But this error does not make sense because my new Java class that extends "Task" looks like this: 但是这个错误没有意义,因为扩展“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;
    }
}

The relevant portion in my build.xml looks like: build.xml中的相关部分如下所示:

<taskdef name="mytask" classname="dec102012.MyAntTask" classpath="dec102012"/>

<target name="main">
    <mytask message="Hello World! MyVeryOwnTask works!"/>
</target>

The problem is the Ant Classloader needs to know where the *.class file sits. 问题是Ant类加载器需要知道* .class文件所在的位置。

Once I changed the build.xml to look like: 一旦我将build.xml更改为:

<taskdef name="mytask" classname="dec102012.MyAntTask" classpath="build/classes"/>

  <target name="main">
    <mytask message="Hello World! MyVeryOwnTask works!"/>
  </target>

it worked (ie it printed out the Hello World message). 它工作(即它打印出Hello World消息)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Ant Build - 找不到任务定义 - Ant Build - taskdef cannot be found 找不到taskdef类org.apache.catalina.ant.InstallTask - taskdef class org.apache.catalina.ant.InstallTask cannot be found 使用classloader AntClassLoader []无法找到ant taskdef类 - ant taskdef class cannot be found using the classloader AntClassLoader[] 蚂蚁 <taskdef> 问题-找不到类名 - Ant <taskdef> problem - classname not found taskdef 类 com.sun.tools.ws.ant.WsImport 无法在“Java Web 服务教程”之后找到 - taskdef class com.sun.tools.ws.ant.WsImport cannot be found Following “The java web services tutorial” Java 和 ProGuard - taskdef class proguard.ant.ProGuardTask 无法使用类加载器 AntClassLoader 找到 - Java and ProGuard - taskdef class proguard.ant.ProGuardTask cannot be found using the classloader AntClassLoader 找不到taskdef类com.sun.javacard.ant.tasks.ConverterTask - taskdef class com.sun.javacard.ant.tasks.ConverterTask cannot be found 找不到taskdef类org.apache.tools.ant.taskdefs.optional.junit.JUnitTask - taskdef class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask cannot be found 我该如何运行ant任务作为前提条件 <taskdef> ? - How can I run an ant task as a prerequisite to <taskdef>? 找不到taskdef类PackageName.ClassName - taskdef class PackageName.ClassName cannot be found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM