tags:

views:

287

answers:

2

I am trying to get ant to run my jsdoc toolkit. After I create my build.xml from the examples at the site, I end up with this:

<taskdef name="jsdoctoolkit" classname="uk.co.darrenhurley.ant.tasks.JsDocToolkit" classpath="/jsdoc/jsrun.jar;/jsdoc/java/classes/js.jar"/>

As I run #ant I get the following error:

/pathto/jsdoc_toolkit-2.3.2/build.xml:1: Unexpected element "{}taskdef" {antlib:org.apache.tools.ant}taskdef

As I am now java developer, I can only guess that my classname ( which I took from the website ) is incorrect. But I have now clue what to replace it with.

can anyone help me with this?

A: 

Your immediate assumption is likely to be incorrect. The XML error you encountered, is telling you that the parser encountered your <taskdef> element in the wrong location within the XML structure. In fact at this point, it hadn't even got around to looking inside the element itself so your classname attribute can't be the problem.

As Pointy says, try posting the entirety of your XML - or at least, have a look at it yourself and check that the <taskdef> element is positioned correctly. It needs to be at the top level of the <project> tag. If you have it nested within other elements, this is not valid and it won't work.

Typically your buildfile might look something like this:

<project name="MyProject" default="dist" basedir=".">
    <description>
        simple example build file
    </description>
  <!-- set global properties for this build -->
  <property name="src" location="src"/>
  <property name="build" location="build"/>
  <property name="dist"  location="dist"/>

  <taskdef name="jsdoctoolkit" classname="uk.co.darrenhurley.ant.tasks.JsDocToolkit" classpath="/jsdoc/jsrun.jar;/jsdoc/java/classes/js.jar"/>

  <!-- Rest of file... -->

In all cases, if you move your taskdef line from where it is now, to directly below the <project> line at the top of the file, I expect this will fix your issue.

Andrzej Doyle
A: 

As You can see, I did this and still get an error.

Here is my code :

<?xml version="1.0" encoding="UTF-8"?>

<target name="generate">
    <jsdoctoolkit 
        jsdochome="/pathto/jsdoc/"
        template="jsdoc" 
        outputdir="/pathto/jsdoc/out/" 
        inputdir="/pathto/js" />
    </target>

and here is the error I get from the ant script:

java.lang.NoSuchFieldError: fileList
    at org.mozilla.javascript.tools.shell.AccessFileList.clearFileList(Unknown Source)
    at uk.co.darrenhurley.ant.tasks.JsDocToolkit.execute(Unknown Source)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:357)
    at org.apache.tools.ant.Target.performTasks(Target.java:385)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
    at org.apache.tools.ant.Main.runBuild(Main.java:758)
    at org.apache.tools.ant.Main.startAnt(Main.java:217)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
wnas