ant: failed to create task or type

Adding the next line in build file solved the problem:

<taskdef resource="net/sf/antcontrib/antlib.xml" />

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.

Tags:

Ant