首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >生成失败的D:\opt\trunk\build.xml:117:无法创建类型为的任务或类型

生成失败的D:\opt\trunk\build.xml:117:无法创建类型为的任务或类型
EN

Stack Overflow用户
提问于 2012-05-02 19:19:40
回答 2查看 4K关注 0票数 3

我已经将antcontri.03.jar添加到ANT_HOME/lib和单独的位置d:\lib中,但它仍然给出这个错误。这里有人能帮我吗?谢谢!

build.properties

代码语言:javascript
复制
#back-end - copy
back.end.dir=d:/opt/polopoly/pear/work/ears/front    
path.to.tomcat.dir=${back.end.dir}/tomcat1,${back.end.dir}/tomcat2,${back.end.dir}/tomcat3, ${back.end.dir}/tomcat3,${back.end.dir}/tomcat4,${back.end.dir}/tomcat5
root.war.file=${path.to.tomcat.dir}/test1.war,${path.to.tomcat.dir}/test2.war,${path.to.tomcat.dir}/test3.war,${path.to.tomcat.dir}/test4.war,${path.to.tomcat.dir}/test5.war

#front-end -paste
host.name=//servername/share
path.to.tomcat.webapps=${host.name}/opt/tomcat/webapps

build.xml

代码语言:javascript
复制
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
  <classpath>
    <pathelement location="d:/lib/ant-contrib-0.3.jar"/>
  </classpath>
</taskdef>

<!-- copy new ROOT.war file -->
<target name="deploy-root" description="Copy new root.war from pCMS back-end to front-end" depends="prepare">
        <sequential>
            <for list="${root.war.file}" param="single-file">
                <echo> Copying File @{single-file} </echo>
                <copy file="@{single-file}" todir="${path.to.tomcat.webapps}" overwrite="true" />
            </for>  
        </sequential>
</target>

输出错误

代码语言:javascript
复制
D:\opt\trunk>ant deploy-root
Buildfile: build.xml
  [taskdef] Could not load definitions from resource lib/net/sf/antcontrib/antcontrib.properties. It could not be found.

init:
     [echo] TODAYS DATE AND TIME: 2 May 2012, 12:16:28 PM, BST

prepare:

deploy-root:

BUILD FAILED
D:\opt\trunk\build.xml:117: Could not create task or type of type: for.

Ant could not find the task or a class this task relies upon.

This is common and has a number of causes; the usual
solutions are to read the manual pages then download and
install needed JAR files, or fix the build file:
 - You have misspelt 'for'.
   Fix: check your spelling.
 - The task needs an external JAR file to execute
     and this is not found at the right place in the classpath.
   Fix: check the documentation for dependencies.
   Fix: declare the task.
 - The task is an Ant optional task and the JAR file and/or libraries
     implementing the functionality were not found at the time you
     yourself built your installation of Ant from the Ant sources.
   Fix: Look in the ANT_HOME/lib for the 'ant-' JAR corresponding to the
     task and make sure it contains more than merely a META-INF/MANIFEST.MF.
     If all it contains is the manifest, then rebuild Ant with the needed
     libraries present in ${ant.home}/lib/optional/ , or alternatively,
     download a pre-built release version from apache.org
 - The build file was written for a later version of Ant
   Fix: upgrade to at least the latest release version of Ant
 - The task is not an Ant core or optional task
     and needs to be declared using <taskdef>.
 - You are attempting to use a task defined using
    <presetdef> or <macrodef> but have spelt wrong or not
   defined it at the point of use

Remember that for JAR files to be visible to Ant tasks implemented
in ANT_HOME/lib, the files must be in the same directory or on the
classpath

Please neither file bug reports on this problem, nor email the
Ant mailing lists, until all of these causes have been explored,
as this is not an Ant bug.
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-05-03 02:05:20

使用:

代码语言:javascript
复制
<taskdef resource="net/sf/antcontrib/antlib.xml">
  <classpath>
    <pathelement location="d:/lib/ant-contrib-0.3.jar"/>
  </classpath>
</taskdef>

而不是。

对于1.6之前的ant版本,antcontrib.properties文件只有taskdefs,其中不包含<for>

票数 2
EN

Stack Overflow用户

发布于 2012-05-02 19:25:56

构建文件中引用了文件D:/opt/trunk/lib/net/sf/antcontrib/antcontrib.properties,但该文件不存在(或当前用户无法访问)。确保它存在,并且允许当前用户读取它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10412680

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档