在用ant编译项目时,有时会碰到build.xml中所定义的任务找不到的问题:
- [root@tivu25 test]# ant -f build.xml local_war
- Buildfile: build.xml
- local_war:
- BUILD FAILED
- /home/haoqf/software/APM/test/build.xml:18: taskdef class com.ibm.team.build.ant.task.LogPublisherTask cannot be found
- Total time: 0 seconds
这是因为ant在当前java的classpath中找不到类
LogPublisherTask(
LogPublisherTask由 org.apache.tools.ant.Task派生而来),这时候需要重新指定当前的classpath,让它包含
LogPublisherTask所属jar库或者class的路径。有三种方法:
1. 在ant命令行指定:
- [root@tivu25 test]# ant -f build.xml local_war -lib /home/haoqf/software/RTC/RTC-BuildSystem-Toolkit-Linux-3.0iFix1/jazz/buildsystem/buildtoolkit/
2. 在build.xml指定:
- <?xml version="1.0" encoding="UTF-8"?>
- <project name="BVT_CVT" default="local_war">
-
- <target name="local_war">
- <taskdef name="logPublisher" classname="com.ibm.team.build.ant.task.LogPublisherTask">
- <classpath>
- <pathelement location="/home/haoqf/software/RTC/RTC-BuildSystem-Toolkit-Linux-3.0iFix1/jazz/buildsystem/buildtoolkit/"/>
- <fileset dir="/home/haoqf/software/RTC/RTC-BuildSystem-Toolkit-Linux-3.0iFix1/jazz/buildsystem/buildtoolkit/">
- <include name="**/*.jar"/>
- </fileset>
- </classpath>
- </taskdef>
-
- <logPublisher repositoryAddress="${repositoryAddress}" />
- </target>
- </project>
3. 设定当前环境变量CLASSPATH:
- [root@tivu25 test]# export CLASSPATH=$CLASSPATH:/home/haoqf/software/RTC/RTC-BuildSystem-Toolkit-Linux-3.0iFix1/jazz/buildsystem/buildtoolkit/com.ibm.team.build.toolkit_2.2.0.v20110308_0258.jar
其中
com.ibm.team.build.toolkit_2.2.0.v20110308_0258.jar包含了类LogPublisherTask的实现。
阅读(21705) | 评论(0) | 转发(0) |