我有一个名为test的目标,我想做一些测试.
我把这里的重要部分放在build.xml中.这包括:
<property name='lib.dir' value='lib' />
<path id='classpath'>
<fileset dir="${lib.dir}" includes="**/*.jar" />
</path>
Run Code Online (Sandbox Code Playgroud)
我在lib目录中放了junit.jar和ant-junit.jar(它是必须的吗?).
但是,如果我跑
ant test
.
输出错误是:
test:
BUILD FAILED
/home/xiaohan/EclipseWorkSpace/AntTest/build.xml:82: Problem: failed to create task or type junit
Cause: the class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask was not found.
This looks like one of Ant's optional components.
Action: Check that the appropriate optional JAR exists in
-/usr/share/ant/lib
-/home/xiaohan/.ant/lib
-a directory added on the command line with the -lib argument
Do not panic, this is a common problem.
The commonest cause is a missing JAR.
This is not a bug; it is a configuration problem
Run Code Online (Sandbox Code Playgroud)
另外,如果我将两个jar文件放在带有$ ANT_HOME设置的/ usr/share/ant/lib中,它仍然无效.
非常感谢任何提示
Luc*_*rin 32
就我而言(使用Mint,基于Debian)
sudo apt-get install ant-optional
Run Code Online (Sandbox Code Playgroud)
是唯一有用的东西.
nul*_*ull 17
安装ant-junit后,基于RHEL的系统解决了这个问题:
$ sudo yum install ant-junit
Run Code Online (Sandbox Code Playgroud)
<property name='lib.dir' value='lib' />
<path id='classpath'>
<fileset dir="${lib.dir}" includes="**/*.jar" />
</path>
Run Code Online (Sandbox Code Playgroud)
这与 Ant 类路径本身无关。它是您可以在任务中使用的属性。您必须将 jar 放入建议的目录或添加命令行参数。
尝试像这样运行它:
ant -lib /path/to/the/ant-junit.jar/ test
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
17552 次 |
最近记录: |