在用ant编译项目时,有时会碰到build.xml中所定义的任务找不到的问题:
这是因为ant在当前java的classpath中找不到类
LogPublisherTask(
LogPublisherTask由 org.apache.tools.ant.Task派生而来),这时候需要重新指定当前的classpath,让它包含
LogPublisherTask所属jar库或者class的路径。有三种方法:
1. 在ant命令行指定:
2. 在build.xml指定:
3. 设定当前环境变量CLASSPATH:
其中
com.ibm.team.build.toolkit_2.2.0.v20110308_0258.jar包含了类
LogPublisherTask的实现。
点击(此处)折叠或打开
- [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
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/
点击(此处)折叠或打开
- ?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>
点击(此处)折叠或打开
- [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