- PR -

Ant実行時のエラーにつきまして

1
投稿者投稿内容
be1300cc
ベテラン
会議室デビュー日: 2002/07/04
投稿数: 88
投稿日時: 2003-12-17 15:35
いつもお世話になっております。be1300ccです。

Ant実行時のエラー内容がイマイチ分かりませんので、質問させて頂きます。
AntにてJunitを実行させる為に、build.xmlを作成したのですが、実行時にエラーが出てしまい、正常に終了しません。

********* build.xml *********
<project name="WSDL2C-TEST" basedir="." default="wsdl2c-junit">

<!-- Build Defaults -->
<property name="src.dir" value="${basedir}/tests/src"/>
<property name="classes.dir" value="${basedir}/tests/classes"/>
<property name="report.dir" value="${basedir}/tests/report"/>

<!-- Junit -->
<target name="wsdl2c-junit">
<junit printsummary="true"> ⇒10行目(エラー部分)
<classpath location="${classes.dir}"/>
<formatter type="xml"/>
<mkdir dir="${report.dir}" />
<batchtest todir="${report.dir}">
<fileset dir="${src.dir}">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
</target>

</project>

********* エラー内容 *********
Buildfile: C:\eclipse\workspace\WSDL2\tests\build.xml

wsdl2c-junit:
[junit] BUILD FAILED: file:C:/eclipse/workspace/WSDL2/tests/build.xml:10: 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.
Total time: 230 milliseconds

ご享受お願いします。
おばけ
ぬし
会議室デビュー日: 2002/11/14
投稿数: 609
お住まい・勤務地: 東京都江東区
投稿日時: 2003-12-17 15:52
引用:

Ant実行時のエラー内容がイマイチ分かりませんので、質問させて頂きます。
(ザックリ)
file:C:/eclipse/workspace/WSDL2/tests/build.xml:10: Could not create task or type of type: junit.

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


そのままですが、「junitというタスクが見つからないか、このタスクのクラスが
見つかりません」とのたまわっています。
junitタスクのクラスをantの実行時のクラスパスに入れなければいけないのでしょう。

JUnit Taskのページによると、
「注釈: (利用者は)junit.jarを持っていなくてはなりません。また<junit>タスクのためのクラスファイルを同じクラスパスの中で動作させねばなりません。以下のいずれかの方法で(利用)出来ます: 」

  • junit.jarオプションのタスクのjarファイルを ANT_HOME/libに置く。
  • どちらも(junit.jar、オプショナルタスクjarファイル)ANT_HOME/libに置かず、代わりにそれらを環境変数CLASSPATHに追加する。
  • 上記のどちらも採用せず、変りにビルドファイルの中の<classpath>を使って指定する。より詳しくは the FAQをご覧下さい。

だそうです。
yuzy
大ベテラン
会議室デビュー日: 2002/02/14
投稿数: 117
投稿日時: 2003-12-17 16:24
antのバージョンが1.5.4より古いと、これと同じようなエラーが出たような記憶があります。
be1300cc
ベテラン
会議室デビュー日: 2002/07/04
投稿数: 88
投稿日時: 2003-12-17 16:28
おばけさん、yuzyさん、アドバイスありがとうございます。
おばけさんの教えて頂いた方法で実行してみたのですが、3つの方法でどれもエラー内容が
変わりませんでした。
Antのバージョンは、1.5.3-1です。

もう少し調べて見たいと思います。
be1300cc
ベテラン
会議室デビュー日: 2002/07/04
投稿数: 88
投稿日時: 2003-12-17 17:14
すみません。
なんとか自己解決できました。

原因は、EclipseのAntの設定の所にtool.jarとjunit.jarの設定が追加されていない
ことが原因でした。

お騒がせしました。

1

スキルアップ/キャリアアップ(JOB@IT)