How do I get javadoc to link to the Java API using an Ant task?
Question
Right now my ant task looks like.
<javadoc sourcepath="${source}" destdir="${doc}">
<link href="http://java.sun.com/j2se/1.5.0/docs/api/" />
</javadoc>
And I'm getting this warning:
javadoc: warning - Error fetching URL: http://java.sun.com/j2se/1.5.0/docs/api/package-list
How do I get the javadoc to properly link to the API? I am behind a proxy.
Solution
You probably need the http.proxyHost and http.proxyPort system properties set. For example, ANT_OPTS="-Dhttp.proxyHost=proxy.y.com" ant doc
Alternatively, you could set the "offline" flag and provide a package list, but that could be a pain for the Java core.
OTHER TIPS
You can also pass the arguments inside the ant task
<arg value="-J-Dhttp.proxyHost=your.proxy.here"/>
<arg value="-J-Dhttp.proxyPort=##"/>
If going the offline link route. Download the package list by going to the URL of the Java API (http://java.sun.com/j2se/1.5.0/docs/api/package-list) and saving it as a text file and then using this Ant task.
<javadoc sourcepath="${source}" destdir="${doc}">
<link offline="true" href="http://java.sun.com/j2se/1.5.0/docs/api/" packagelistloc="path-containing-package-list"/>
</javadoc>
You can also use the "offline" mode that allows you to build (faster!) without accessing the internet. Please see this answer: https://stackoverflow.com/a/24089805/366749