You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ke...@apache.org on 2007/08/24 03:13:10 UTC

svn commit: r569208 - /maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java

Author: kenney
Date: Thu Aug 23 18:13:10 2007
New Revision: 569208

URL: http://svn.apache.org/viewvc?rev=569208&view=rev
Log:
This commit adds all reactor project's apidocs to the search path for external
links. It is related to MJAVADOC-97, but only deals with reactor projects.

Only already built reactor projects are added.
The OfflineLink is used to preserve the official site link (using the pom's url with '/apidocs' appended),
and the real location will be the project's javadoc output directory.

Issues/Todo's:
- it is assumed that remote javadoc's are indeed in the project's '/apidocs' uri
- it is assumed that the relative path from the current project to the generated javadocs
  ('target/site/apidoc' or something) is the same for all reactor projects.
- also add links to other, non-reactor dependencies - but configurable.
- when using site:stage, that mojo will replace all URLs in the poms to a huge relative
  path which goes up way too far (bug in pathtool?). So these links may not work
  in a staged site. This however has nothing to do with this commit as far as I can see;
  maybe site:stage is broken...

Fix for the first two: somehow get the javadoc plugin configuration for each reactor project
and read the values there (and interpolate them). Something similar as is done in the eclipse
plugin, which read's the compiler plugin's <source> element, can be done here.

The offline link approach was taken because if you use the real urls then the first
deploy will always fail since the site isn't up yet. This also works fine in offline mode.


Modified:
    maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java?rev=569208&r1=569207&r2=569208&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java Thu Aug 23 18:13:10 2007
@@ -2260,6 +2260,35 @@
      */
     private void addLinkofflineArguments( List arguments )
     {
+        if ( !aggregate && reactorProjects != null )
+        {
+            String javadocDirRelative = PathUtils.toRelative( project.getBasedir(), getOutputDirectory() );
+
+            for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
+            {
+                MavenProject p = (MavenProject) it.next();
+
+                // don't add projects that have not built yet.
+                if ( p.getId().equals( project.getId() ) )
+                {
+                    break;
+                }
+                
+                if ( p.getUrl() != null )
+                {
+                    if ( offlineLinks == null )
+                    {
+                        offlineLinks = new ArrayList();
+                    }
+
+                    OfflineLink ol = new OfflineLink();
+                    ol.setUrl( p.getUrl() + "/apidocs" );
+                    ol.setLocation( p.getBasedir().getAbsolutePath() + "/" + javadocDirRelative );
+                    offlineLinks.add( ol );
+                }
+            }
+        }
+
         if ( offlineLinks != null )
         {
             for ( int i = 0; i < offlineLinks.size(); i++ )
@@ -2303,6 +2332,7 @@
 
                 try
                 {
+                    // XXX links can be relative paths or files - they're not necessarily URLs.
                     URL linkUrl = new URL( link + "/package-list" );
                     fetchURL( settings, linkUrl );
                     addArgIfNotEmpty( arguments, "-link", quotedPathArgument( link ), true );