ant: failed to create task or type

前端 未结 3 1008
隐瞒了意图╮
隐瞒了意图╮ 2021-01-04 03:37

(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.)

I\'ve created a custom

相关标签:
3条回答
  • 2021-01-04 04:11

    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:

    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.

    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.

    0 讨论(0)
  • 2021-01-04 04:14

    Adding the next line in build file solved the problem:

    <taskdef resource="net/sf/antcontrib/antlib.xml" />
    
    0 讨论(0)
  • 2021-01-04 04:22

    For me this message:

    /Users/packrd/Downloads/source/build.xml:435: The following error occurred while executing this line:
    /Users/packrd/Downloads/source/build.xml:440: The following error occurred while executing this line:
    /Users/packrd/Downloads/source/Documentation/docs/build.xml:221: The following error occurred while executing this line:
    /Users/packrd/Downloads/source/Documentation/docs/asciidoc-macros.xml:249: Problem: failed to create task or type antlib:net.sf.antcontrib:switch
    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.
    No types or tasks have been defined in this namespace yet
    
    This appears to be an antlib declaration. 
    Action: Check that the implementing library exists in one of:
            -/usr/local/Cellar/ant/1.10.8/libexec/lib
            -/Users/packrd/.ant/lib
            -a directory added on the command line with the -lib argument
    

    meant I didn't have ant-contrib installed, fix on OS X:

    brew install ant-contrib

    0 讨论(0)
提交回复
热议问题