This might be a doclet-implementation-specific question, but I believe its really a JavaDoc configuration issue I'm dealing with here.
I'm trying to get the yDoc UML Doclet to work so that it will generate UML diagrams for my Java app as part of the Ant build. I downloaded the project (community edition) and have tried adapting their build-sample.xml
but can't quite get it to work.
Here's my project directory structure:
MyProject/
src/main/java/
<All the Java sources I want documented and diagrammed>
bin/main
<Compiled binaries of src/main/java/>
lib/
styleed.jar
ydoc.jar
resources/
<All the yDoc resources that came with the download>
umldoclet/
<Where I want all JavaDocs to go>
build.xml
Here's build.xml
:
<project name="MyProject" default="ydoc" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant" xmlns:jacoco="antlib:org.jacoco.ant">
<!-- The "compile" task and all its dependencies omitted for brevity,
but they all absolutely work 100% and "compile" places compiled
CLASS files under bin/main. -->
<target name="ydoc" depends="compile">
<property name="ydoc.home" value="${basedir}"/>
<javadoc source="1.5" destdir="./umldoclet" additionalparam="-breakiterator">
<packageset dir="src/main">
<include name="java/**"/>
</packageset>
<doclet name="ydoc.doclets.YStandard" path="${ydoc.home}/lib/ydoc.jar;${ydoc.home}/resources">
<param name="-author"/>
<param name="-generic"/>
<param name="-umlautogen"/>
<param name="-filterpath" value="./lib/ydoc.jar"/>
<param name="-filter" value="ydoc.filters.ExcludeFilter"/>
<param name="-tag" value="y.precondition"/>
<param name="-tag" value="y.postcondition"/>
<param name="-tag" value="y.complexity"/>
<param name="-tag" value="param"/>
<param name="-tag" value="return"/>
<param name="-tag" value="see"/>
<param name="-tag" value="y.uml"/>
</doclet>
</javadoc>
</target>
</project>
When I run the ydoc
task, even running Ant in "verbose" mode with the -v
argument, I see the [ydoc]
task getting called in the Ant Console, followed by a log statement that reads "Generating Javadoc" and about 20 lines from the verbose output regurgitating the yDoc
params back to me, then a final log message saying "Javadoc execution". Then, the following stunningly-vague IOException
:
BUILD FAILED
<my-eclipse-home>/MyProject/build.xml:200: Javadoc failed: java.io.IOException: Cannot run program "javadoc": java.io.IOException: error=2, No such file or directory
at org.apache.tools.ant.taskdefs.Javadoc.execute(Javadoc.java:1765)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
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:392)
at org.apache.tools.ant.Target.performTasks(Target.java:413)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:424)
at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:138)
Caused by: java.io.IOException: Cannot run program "javadoc": java.io.IOException: error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:475)
at java.lang.Runtime.exec(Runtime.java:610)
at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Execute.java:862)
at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:481)
at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:495)
at org.apache.tools.ant.taskdefs.Javadoc.execute(Javadoc.java:1759)
... 15 more
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.<init>(UNIXProcess.java:164)
at java.lang.ProcessImpl.start(ProcessImpl.java:81)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:468)
... 20 more
Is there any way to get more details out of Ant? To find out what file or directory its referring to in the exception? Any JavaDoc/yDoc gurus ever ran into this before? Is my project directory structure set up incorrectly, or different than what the Ant build is looking for? I believe I have my doclet/path
attribute set up correctly, and using the correct path separators (I'm on Ubuntu Linux). For the life of me I can't figure out where to go from here, or how to go about diagnosing the underlying issue here! Thanks in advance!
Edit/Update:
Thanks to everyone so far for the suggestions. I am doing away with Eclipse totally (as far as the build is concerned and just running Ant from the command-line; this is fine for now. When I do this, I get a successful build (so Eclipse was at least partly the culprit), however still no yDoc generation.
Now, when I run Ant from the terminal with the verbos (-v
) option, here's what I see:
Hundreds of warnings that look the same, but with different classes:
[javadoc] Constructing Javadoc information...
[javadoc] /<path-to-my-project>/MyProject/src/main/java/com/some/pkg/SomeObject.java:11: package org.springframework.beans.factory.annotation does not exist
[javadoc] import org.springframework.beans.factory.annotation.Autowired;
[javadoc] ^
After hundreds of those, I get the following output (1 of these for every package in my source tree):
[javadoc] javadoc: warning - No source files for package java.com.some.pkg.<whatever>
Last, the final section of the verbose build output:
[javadoc] Valid license file found.
[javadoc] Registered Filter ydoc.filters.ExcludeFilter ...
[javadoc] Registered Taglet for tag @y.complexity ...
[javadoc] Registered Taglet for tag @y.precondition ...
[javadoc] Registered Taglet for tag @y.postcondition ...
[javadoc] Registered Taglet for tag @y.author ...
[javadoc] 1 error
[javadoc] 109 warnings
[javadoc] javadoc: error - No public or protected classes found to document.
BUILD SUCCESSFUL
Total time: 6 seconds
Furthermore, if it were executing correctly, it should be places all the JavaDocs under the uml-doclet/
directory in my project root. It does no such thing!
So it looks like there are several more things going on:
- The JavaDoc can't see my 3rd party dependencies (such as Spring, Camel, etc.); hence the list of hundreds of warnings
- It can't find any of my sources to document
Again, the bounty goes to anyone who can help me get this working. Thanks again for all the help so far!