【发布时间】:2011-12-19 15:32:05
【问题描述】:
(是的,我已经阅读并根据对本论坛和许多其他论坛(例如 JavaRanch)中类似问题的回答进行了尝试,但无济于事。)
我根据 Apache 文档创建了一个自定义的 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 文件中的一个目标:
<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>
我在路径 *$ANT_HOME/lib* 上有 ant-contrib-1.0b3.jar。我在那个路径上有 sqlscriptpreprocessor.jar,还有我构建的本地类路径。
为了解决这个问题,我尝试了以下一组语句的每种组合,这些语句是我通过谷歌到处收集的,意思是
<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>
令人沮丧的是,给ant添加自定义任务并没有他们说的那么容易。
我将非常感谢所有 cmets。
谢谢,
罗斯
【问题讨论】:
标签: ant