在jar中找不到资源.未能创建任务或类型类路径



我在ant中有以下问题:

[taskdef] Could not load definitions from resource net/sf/antcontrib/antcontri
b.properties. It could not be found.
BUILD FAILED
build.xml:5: Problem:
failed to create task or type classpath
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.

运行如下ant build.xml:

<?xml version="1.0"?>
<project default="main" basedir=".">    
    <taskdef resource="net/sf/antcontrib/antcontrib.properties" />
    <classpath>
      <fileset dir=".">
        <include name="**/*.jar" />
      </fileset>
    </classpath>
    <target name="main">
    </target >
</project>

虽然,运行

<project default="main" basedir=".">    
    <path id="path.svnant">
        <pathelement location="${basedir}/ant-contrib-1.0b3.jar" />
    </path>
    <typedef resource="net/sf/antcontrib/antcontrib.properties" classpathref="path.svnant" />
    <target name="main">
    </target >
</project>

没有任何错误。

所以问题是为什么第一个build.xml是错误的?

我想是因为<classpath/>元素一定在</taskdef>元素里面。

<taskdef resource="net/sf/antcontrib/antcontrib.properties" >
   <classpath>
      <fileset dir=".">
         <include name="**/*.jar" />
      </fileset>
   </classpath>
</taskdef>

相关内容

  • 没有找到相关文章