Ant task doesn't work in Eclipse

转载 2006年06月01日 17:25:00
Here's another solution to a problem I'm hoping to get Googled: If you're running an Ant build.xml file in Eclipse, the <junit> task will not work by default. If you attempt to use the <junit> task with a fresh install of Eclipse, you will receive the following error message:

BUILD FAILED: [ECLIPSE_DIR]/workspace/[PROJECT_DIR]/build.xml:208: Could not create task or type of type: junit.

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 'junit'.
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 optional.jar is absent
Fix: look for optional.jar in ANT_HOME/lib, download if needed
- The task was not built into optional.jar as dependent
libraries were not found at build time.
Fix: look in the JAR to verify, then rebuild with the needed
libraries, or download a 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>.

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.

The <junit> Ant task is an optional task and this is the standard Ant error message when Ant cannot find the supporting code for an optional task. Ant includes support for the tasks themselves, but not the internal code that actually does the work.

So you need to find a copy of junit.jar, the code that does JUnit work, and tell Ant where it is. The easiest way to do this is to go to Window --> Preferences, Ant --> Runtime. In the Classpath tab click on Global Entries and then Add External JARs....

Eclipse already has a copy of JUnit, so in the dialog find your Eclipse plugins directory ([ECLIPSE_DIR]/plugins/) and go to the JUnit plugin (presently org.junit_3.8.1) and select junit.jar. Now all of your Ant scripts will know how to do the <junit> Ant task.

Posted at September 08, 2004 at 08:27 AM EST
Last updated September 08, 2004 at 08:27 AM EST

引自:http://www.ryanlowe.ca/blog/archives/001038_junit_ant_task_doesnt_work_in_eclipse.php


Jmeter+ant批量运行脚本,ant配置说明

一.环境配置: 1.需要安装JDK1.6以上版本:http://www.oracle.com/technetwork/java/javase/downloads/index.html  验证是否安...
  • bigbigworlddidi
  • bigbigworlddidi
  • 2017年06月08日 11:51
  • 296

Ant环境配置、生成测试报告以及问题的解决

ant的下载配置、编写build.xml执行ant产生报告、使用ant时出现的错误及解决
  • DearMorning
  • DearMorning
  • 2017年05月03日 15:40
  • 778

理解storm的并行执行,workder,executor,task的关系以及调度算法

官方对storm中worker,executor,task讲解非常清楚,https://github.com/nathanmarz/storm/wiki/Understanding-the-paral...
  • wawmg
  • wawmg
  • 2015年01月29日 15:38
  • 5293

iOS 如何pop到指定页面

当我们做app的时候有时候会遇到这样的需求,根视图是A一个“个人信息” 页面,点击头像会push到“个人详细信息”的B页面,当我们点击某一个详细的信息进行修改时会push到“修改信息”的C页面(或者会...
  • q375537943
  • q375537943
  • 2016年08月02日 11:06
  • 779

Android4.4制作自有SDK探析

Android4.4制作自有SDK探析        最近研究了一下android4.4制作自有SDK的东西。我们都知道,拿到Google的原始代码后,芯片公司会把它结合芯片去平台化,再发出芯片公司的...
  • sundesheng125
  • sundesheng125
  • 2015年04月11日 16:32
  • 5530

装完mysql启动报错:“Table ‘mysql.plugin’ doesn’t exist” 解决方法

装完mysql后启动mysql发现启动不了,错误日志里面会提示Table ‘mysql.plugin’ doesn’t exist,出现此错误的原因有两种。 一种是装完mysql之后没有运行初始...
  • lcathm
  • lcathm
  • 2015年12月15日 14:03
  • 8654

Apache Ant中任务(Task)的执行原理实例说明

前言:Ant工具是采用纯Java语言编写的一款自动化构建、编译、部署的工具,与Apache基金组织下的Maven工具类似,只是Maven后来的一些新功能,使得Maven比Ant工具更加优秀。至于Ant...
  • limingzhong198
  • limingzhong198
  • 2014年03月26日 23:20
  • 3996

win7下Apache ant的安装与配置

下载Apache antapache-ant-1.9.4
  • renyp8799
  • renyp8799
  • 2014年05月27日 18:32
  • 1678

在qemu中运行magenta

前面已经编译了magenta内核 并且准备好了qemu模拟器 进入magenta目录 看下脚本./scripts/run-magenta-x86-64 ~/fuchsia/magent...
  • zahuopuboss
  • zahuopuboss
  • 2016年08月18日 14:15
  • 2249

有了Eclipse为何用Ant

总有那么一批人认为IDE是无比强大的,比如Eclipse,或者更强大的MyEclipse(你是不是在用破解版本?)。Eclipse的确非常、非常、非常的优秀,它能帮你自动编译、帮你执行单元测试、帮你重...
  • ricefcc
  • ricefcc
  • 2015年02月03日 23:14
  • 1639
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章: Ant task doesn't work in Eclipse
举报原因:
原因补充:

(最多只允许输入30个字)