Hi,
we have a http proxy at work that needs authentication. If I want to
have links in my Javadocs to other libraries I use, I can't use the
normal mechanism
(http://maven.apache.org/reference/plugins/javadoc/faq.html#firewall).
However, plugin:download manages to get through the firewall, so the
javadoc should be able to do it also. I changed the goal
"maven-javadoc-plugin:report" in the javadoc plugin like this:
<j:set var="proxyOnline" value="${maven.javadoc.mode.proxy.online}"/>
<ant:echo>proxy mode: ${proxyOnline}</ant:echo>
<j:choose>
<j:when test="${proxyOnline}">
<!-- Use proxy only mode-->
<ant:mkdir dir="${maven.build.dir}/packagelists"/>
<util:tokenize var="links" delim=","
trim="true">${maven.javadoc.links}</util:tokenize>
<j:forEach var="link" items="${links}"
indexVar="linkNr">
<ant:echo>Downloading API information from
${link.trim()} ...</ant:echo>
<j:set var="remoteFile"
value="${link.trim()}package-list"/>
<util:file var="localFile"
name="${maven.build.dir}/packagelists/${linkNr}-package-list" />
<ant:echo>downloading ${remoteFile} to
${localFile}</ant:echo>
<j:catch var="ex">
<j:invokeStatic var="dummy" method="getFile"
className="org.apache.maven.util.HttpUtils">
<j:arg type="java.lang.String"
value="${remoteFile}" />
<j:arg type="java.io.File"
value="${localFile}"/>
<j:arg type="boolean" value="false"/>
<j:arg type="boolean" value="true"/>
<j:arg type="java.lang.String"
value="${maven.proxy.host}" />
<j:arg type="java.lang.String"
value="${maven.proxy.port}" />
<j:arg type="java.lang.String"
value="${maven.proxy.username}" />
<j:arg type="java.lang.String"
value="${maven.proxy.password}" />
<j:arg type="boolean" value="false"/>
</j:invokeStatic>
</j:catch>
<ant:echo>${ex}</ant:echo>
<ant:echo>${ex.printStacktrace()}</ant:echo>
</j:forEach>
</j:when>
<j:otherwise>
<!-- calculate online/offline mode -->
<j:set var="online"
value="${maven.javadoc.mode.online}"/>
<j:if test="${empty(online)}">
<j:set var="online"
value="${maven.mode.online}"/>
</j:if>
<j:choose>
<j:when test="${online}">
<util:tokenize var="links" delim=","
trim="true">${maven.javadoc.links}</util:tokenize>
<j:forEach var="link" items="${links}">
<ant:echo>Linking with API information
from ${link.trim()} ...</ant:echo>
</j:forEach>
</j:when>
<j:otherwise>
<util:tokenize var="links" delim=","
trim="true">${maven.javadoc.offlineLinks}</util:tokenize>
<j:forEach var="link" items="${links}">
<ant:echo>Linking offline API
information from ${link.trim()}
...</ant:echo>
</j:forEach>
</j:otherwise>
</j:choose>
</j:otherwise>
</j:choose>
Basically, it uses the HttpUtils class to download the package-list's
into a directory 'package-lists'. To make a difference, I prepended
the files with a number.
Suppose I have this:
maven.javadoc.links=http://java.sun.com/j2se/1.5.0/docs/api/,http://jakarta.apache.org/commons/lang/api/
I can now generate the offline links
(http://maven.apache.org/reference/plugins/javadoc/faq.html#offlineLinks):
maven.javadoc.offlineLinks=http://java.sun.com/j2se/1.5.0/docs/api/#${path.to.downloaded.packagelists}/1-package-list,http://jakarta.apache.org/commons/lang/api/#${path.to.downloaded.packagelists}/2-package-list
then I only need to set the mode to offline, and I should get nice
links in my javadocs.
How can I create that "maven.javadoc.offlineLinks" variabel on the fly?
regards,
Wim
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]