I found how to create the variable on the fly using <j:new/>. I now
have this piece of code that downloads the package-list automatically
and generates the correct links for when you are stuck behind a
firewall that needs authentication. However it does not work! Is the
Javadoc plugin responsible on this mailinglist and could he try to
help me out?

regards,

Wim
<goal name="maven-javadoc-plugin:report"
        description="Generate API documentation" prereqs="xdoc:init">

       ... some initialization about the year...

        <j:set var="proxyOnline" value="${maven.javadoc.mode.proxy.online}"/>
        <ant:echo>proxy mode: ${proxyOnline}</ant:echo>
        <j:if 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:mkdir 
dir="${maven.build.dir}/packagelists/${linkNr}"/>
                        <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>
                        <j:if test="${!empty(ex)}">
                                <ant:echo>${ex}</ant:echo>
                        </j:if>
                  </j:forEach>

                  <j:set var="maven.javadoc.mode.online" value="false"/>
                  <ant:echo>Creating buffer to generate correct 
offlineLinks</ant:echo>
                  <j:new var="linksBuffer" className="java.lang.StringBuffer"/>
                  <j:forEach var="link" items="${links}" indexVar="linkNr">
                        <ant:echo>Appending
'${link}#${maven.build.dir}/packaglists/${linkNr}/package-list' to
buffer </ant:echo>
                        <j:invoke method="append" on="${linksBuffer}">
                                <j:arg type="java.lang.String"
value="${link}#${maven.build.dir}/packaglists/${linkNr},"/>
                        </j:invoke>
                  </j:forEach>

                  <j:set var="maven.javadoc.offlineLinks" 
value="${linksBuffer.toString()}"/>
                  <ant:echo>${maven.javadoc.offlineLinks}</ant:echo>
        </j:if>

       <!-- calculate online/offline mode -->
       ... rest of the goal...
</goal>


On 4/19/05, Wim Deblauwe <[EMAIL PROTECTED]> wrote:
> 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]

Reply via email to