蚂蚁:无法创建任务或类型 [英] ant: failed to create task or type

查看:124
本文介绍了蚂蚁:无法创建任务或类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(是的,我已经阅读并基于答案在这个论坛和许多其他如JavaRanch的类似的问题起到左右 - 但无济于事)

(Yes, I've read and played around based on answers to similar questions in this forum and in many others such as JavaRanch--to no avail yet.)

我根据Apache的文档中创建一个定制Ant任务。

I've created a custom ant task according to Apache doc.

运行ant,我得到:

BUILD FAILED
/home/russ/blackpearl/fun/build.xml:121: Problem: failed to create task or type sqlscriptpreprocessor
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
at org.apache.tools.ant.UnknownElement.getNotFoundException(UnknownElement.java:487)
at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:419)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:163)
at org.apache.tools.ant.Task.perform(Task.java:347)

这是在按照一个目标我的的build.xml 的文件:

This is pursuant to a target in my build.xml file:

<target name="mysql-preprocess"
        description="Preprocess MySQL database scripts into one file">
    <sqlscriptpreprocessor inputfilepath="${basedir}/extras/blackpearl.sql.in"
                          outputfilepath="${basedir}/extras/blackpearl.sql" />
</target>

我的蚂蚁的contrib-1.0b3.jar 的路径* $ ANT_HOME / lib目录*上。我的 sqlscript preprocessor.jar 的这条道路上,加上我的构建本地CLASSPATH中。

I have ant-contrib-1.0b3.jar on the path *$ANT_HOME/lib*. I have sqlscriptpreprocessor.jar on that path, plus the local classpath for my build.

在试图驱走这个问题,我已经试过了下面一组语句,我已经拿起各地通过谷歌的地方,每一个组合,意在&lt之一;的taskdef蚂蚁的contrib&GT;同的&lt之一;的taskdef sqlscript preprocessor&GT;构建体,两个第一与后者中的一个,两个,后者的第一个,都在一起,其中没有等

In an attempt to exorcise this problem, I've tried every combination of the following set of statements, which I've picked up all over the place via Google, meaning one of the <taskdef ant-contrib> with one of the <taskdef sqlscriptpreprocessor> constructs, two of the first with one of the latter, one of the first with two of the latter, all together, none of them, etc.

<taskdef resource="net/sf/antcontrib/antlib.xml" />
<taskdef resource="net/sf/antcontrib/antcontrib.properties" />
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
    <classpath>
        <pathelement location="/home/russ/dev/downloads/ant-contrib/ant-contrib-1.0b3.jar" />
    </classpath>
</taskdef>

<taskdef name="sqlscriptpreprocessor" classname="com.etretatlogiciels.ant.task.SqlScriptPreprocessor" />
<taskdef resource="${basedir}/lib/ant-tasks/SqlScriptPreprocessor.properties"
         classpath="${basedir}/lib/ant-tasks/sqlscriptpreprocessor.jar" />
<taskdef resource="${basedir}/lib/ant-tasks/SqlScriptPreprocessor.properties">
    <classpath>
        <pathelement location="${basedir}/lib/ant-tasks/sqlscriptpreprocessor.jar" />
    </classpath>
</taskdef>

这是令人沮丧的,它不是像他们说的自定义任务添加到蚂蚁一样容易。

It's frustrating that it's not as easy as they say to add custom tasks to ant.

我将不胜AP preciate任何和所有的意见。

I would greatly appreciate any and all comments.

谢谢,

拉​​斯

推荐答案

我这个现在挣扎了两天。我出现这个问题的答案越来越由<一个暗示href=\"http://ant.apache.org/manual/tutorial-writing-tasks.html\">http://ant.apache.org/manual/tutorial-writing-tasks.html:

I've struggled with this for two days now. The answer I appear to be getting is implied by http://ant.apache.org/manual/tutorial-writing-tasks.html:

在&lt; 的taskdef NAME =sqlscript preprocessor...&GT;元件必须放置向下使用它的目标内,在这种情况下,的 mysql- preprocess 的。我没有这样做。现在,我有:

The <taskdef name="sqlscriptpreprocessor" ...> element must be placed down inside the target that uses it, in this case, mysql-preprocess. I was not doing this. Now, I have:

<target name="mysql-preprocess"
        description="Preprocess MySQL database scripts into one file">
    <taskdef name="sqlscriptpreprocessor"
             classname="com.etretatlogiciels.ant.task.SqlScriptPreprocessor"
             classpath="${basedir}/lib/ant-tasks/sqlscriptpreprocessor.jar" />
    <sqlscriptpreprocessor inputfilepath="${basedir}/extras/blackpearl.sql.in"
                          outputfilepath="${basedir}/extras/blackpearl.sql" />
</target>

我不明白为什么我的自定义任务必须在消耗它的目标元素来定义,但这是没意见。我不能肯定这是因为措辞优雅,因为它可以,但它现在的作品。

I don't understand why my custom task must be defined in the target element that consumes it, but this is fine by me. I'm not certain this is couched as gracefully as it could be, but it works now.

我回答我自己的问题遗憾;它一次或两次发生之前,似乎我的pretty跛。我只希望它可以帮助别人。

I'm sorry for answering my own question; it's happened before once or twice and it seems pretty lame of me. I just hope it helps someone else.

感谢周围所有的论坛和帖子这个话题我读了最近两天的所有答复。

Thanks for all the replies surrounding this topic in all the forums and posts I read over the last two days.

这篇关于蚂蚁:无法创建任务或类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆