简体   繁体   中英

Generating Javadoc from Eclipse created ant script

I am trying to make an ant script that will create a release package for my project. I have started by generating a Javadoc ant script using the Generate Javadoc command in the Eclipse gui.

The generated script is as follows

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="javadoc">
<target name="javadoc">
    <javadoc access="protected" author="true" classpath="C:\Eclipse\workspace\JetstreamSDK-Java\JetstreamSDK-Java\resources\libraries\jaxb-2.2.7\lib\jaxb-impl.jar;C:\Eclipse\workspace\JetstreamSDK-Java\JetstreamSDK-Java\resources\libraries\httpcomponents-client-4.2.5\lib\httpclient-4.2.5.jar;C:\Eclipse\workspace\JetstreamSDK-Java\JetstreamSDK-Java\resources\libraries\httpcomponents-client-4.2.5\lib\commons-codec-1.6.jar;C:\Eclipse\workspace\JetstreamSDK-Java\JetstreamSDK-Java\resources\libraries\jaxb-2.2.7\lib\jaxb-xjc.jar;C:\Eclipse\workspace\JetstreamSDK-Java\JetstreamSDK-Java\resources\libraries\jaxb-2.2.7\lib\jaxb-api.jar;C:\Eclipse\workspace\JetstreamSDK-Java\JetstreamSDK-Java\resources\libraries\jaxb-2.2.7\lib\jaxb-core.jar;C:\Eclipse\workspace\JetstreamSDK-Java\JetstreamSDK-Java\resources\libraries\httpcomponents-client-4.2.5\lib\httpcore-4.2.4.jar;C:\Eclipse\workspace\JetstreamSDK-Java\JetstreamSDK-Java\resources\libraries\httpcomponents-client-4.2.5\lib\commons-logging-1.1.1.jar;C:\Eclipse\workspace\JetstreamSDK-Java\JetstreamSDK-Java\resources\libraries\commons-configuration-1.9\commons-configuration-1.9.jar;C:\Eclipse\workspace\JetstreamSDK-Java\JetstreamSDK-Java\resources\libraries\jaxb-2.2.7\lib\jaxb-jxc.jar;C:\Eclipse\workspace\JetstreamSDK-Java\JetstreamSDK-Java\resources\libraries\commons-lang-2.6\commons-lang-2.6.jar" destdir="C:\Users\jender\Desktop\javadoc" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" packagenames="com.TersoSolutions.Jetstream.SDK.XML.Events.LogicalDeviceAddedEvent,com.TersoSolutions.Jetstream.SDK.XML.Model.GetConfigurationResponse,com.TersoSolutions.Jetstream.SDK.XML.Model.ConfigureResponse,com.TersoSolutions.Jetstream.SDK.XML.Events.ObjectEvent,com.TersoSolutions.Jetstream.SDK.XML.Events.CommandQueuedEvent,com.TersoSolutions.Jetstream.SDK.XML.Model.CommandResponse,com.TersoSolutions.Jetstream.SDK.Application.User.DeviceSpecificCommands.TS,com.TersoSolutions.Jetstream.SDK.XML,com.TersoSolutions.Jetstream.SDK.Application.User,com.TersoSolutions.Jetstream.SDK.Application.Events,com.TersoSolutions.Jetstream.SDK.XML.Events.SensorReadingEvent,com.TersoSolutions.Jetstream.SDK.XML.Events.DeviceFailureEvent,com.TersoSolutions.Jetstream.SDK.XML.Model.RemoveEventsResponse,com.TersoSolutions.Jetstream.SDK.XML.Events.HeartbeatEvent,com.TersoSolutions.Jetstream.SDK.XML.Model.GetDeviceDefinitionsResponse,com.TersoSolutions.Jetstream.SDK.XML.Events.LogicalDeviceRemovedEvent,com.TersoSolutions.Jetstream.SDK.XML.Events.CommandCompletionEvent,com.TersoSolutions.Jetstream.SDK.XML.Events.LogEntryEvent,com.TersoSolutions.Jetstream.SDK.Application,com.TersoSolutions.Jetstream.SDK.XML.Events.DeviceRestoreEvent,com.TersoSolutions.Jetstream.SDK.XML.Model.GetPoliciesResponse,com.TersoSolutions.Jetstream.SDK.XML.Model.GetEventsResponse,com.TersoSolutions.Jetstream.SDK.XML.Events.AggregateEvent" source="1.7" sourcepath="C:\Eclipse\workspace\JetstreamSDK-Java\JetstreamSDK-Java\src" splitindex="true" use="true" version="true"/>
</target>
</project>

Before moving forward I decided to test the script, but I cannot get it to run properly. I have attempted to run the script with the following commands

ant javadoc -buildfile javadoc_protected.xml 

ant javadoc -buildfile javadoc_protected.xml C:\Program Files\Java\jdk1.7.0_25\bin\javadoc.exe

ant javadoc -buildfile javadoc_protected.xml "C:\Program Files\Java\jdk1.7.0_25\bin\javadoc.exe"

And after the above didn't work I read through the http://ant.apache.org/manual/Tasks/javadoc.html page and tried

ant javadoc -buildfile javadoc_protected.xml -executable C:\Program Files\Java\jdk1.7.0_25\bin\javadoc.exe

but I am still having no luck. I am extremely inexperienced with ant and I would appreciate if someone can explain what I am doing wrong.

If you post the error message you are getting it will help a lot...

Without having seen the error, this is my suggestion:

1) Put your build file in a file called "build.xml"

2) In this directory where you put the build.xml file, try executing ant javadoc (in a command window -Start menu, Execute, cmd-)

3) If you are getting an error message saying "Cannot run program javadoc.exe", then you haven't javadoc.exe in the Path of your system. So, to add the JDK to the path (assuming you are using a Windows OS) you need to open a command window and type

set Path="C:\Program Files\Java\jdk1.7.0_25\bin";%Path%

Don't forget the quotes!

4) Execute

ant javadoc 

within the directory of the build.xml file, that's all!

This is a simple build.xml I have used to test this:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="javadoc">
<target name="javadoc">
    <javadoc access="protected" author="true" sourcepath="C:\workspace\ZeSwing\src" destdir="C:\workspace\ZeSwing\docs"/>
</target>
</project>

Hope it helps! (Or maybe, given the date of your post... that you have found the solution elsewhere)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM