You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by vs...@apache.org on 2009/07/18 14:16:55 UTC

svn commit: r795352 - in /maven/plugins/trunk/maven-javadoc-plugin: ./ src/it/MJAVADOC-97/ src/it/MJAVADOC-97/module1/ src/it/MJAVADOC-97/module1/src/ src/it/MJAVADOC-97/module1/src/main/ src/it/MJAVADOC-97/module1/src/main/java/ src/it/MJAVADOC-97/mod...

Author: vsiveton
Date: Sat Jul 18 12:16:54 2009
New Revision: 795352

URL: http://svn.apache.org/viewvc?rev=795352&view=rev
Log:
MJAVADOC-97: enable internal/external dependency references as links 

o better use of offlineLinks for multi modules
o fix some TODO defined in r569208 
o added IT
o updated documentation

Added:
    maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/
    maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/goals.txt   (with props)
    maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module1/
    maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module1/pom.xml   (with props)
    maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module1/src/
    maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module1/src/main/
    maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module1/src/main/java/
    maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module1/src/main/java/com/
    maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module1/src/main/java/com/mycompany/
    maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module1/src/main/java/com/mycompany/app/
    maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module1/src/main/java/com/mycompany/app/App.java   (with props)
    maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module2/
    maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module2/pom.xml   (with props)
    maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module2/src/
    maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module2/src/main/
    maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module2/src/main/java/
    maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module2/src/main/java/com/
    maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module2/src/main/java/com/mycompany/
    maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module2/src/main/java/com/mycompany/app2/
    maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module2/src/main/java/com/mycompany/app2/App2.java   (with props)
    maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/pom.xml   (with props)
    maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/verify.bsh
Modified:
    maven/plugins/trunk/maven-javadoc-plugin/pom.xml
    maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractFixJavadocMojo.java
    maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
    maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocUtil.java
    maven/plugins/trunk/maven-javadoc-plugin/src/site/fml/faq.fml
    maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/FixJavadocMojoTest.java

Modified: maven/plugins/trunk/maven-javadoc-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/pom.xml?rev=795352&r1=795351&r2=795352&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/pom.xml Sat Jul 18 12:16:54 2009
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-plugins</artifactId>
-    <version>13</version>
+    <version>14-SNAPSHOT</version>
     <relativePath>../pom.xml</relativePath>
   </parent>
 
@@ -262,6 +262,7 @@
                 <pomInclude>**/MJAVADOC-194/pom.xml</pomInclude>
                 <pomInclude>**/MJAVADOC-206/pom.xml</pomInclude>
                 <pomInclude>**/MJAVADOC-226/pom.xml</pomInclude>
+                <pomInclude>**/MJAVADOC-97/pom.xml</pomInclude>
               </pomIncludes>
               <postBuildHookScript>verify</postBuildHookScript>
               <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>

Added: maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/goals.txt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/goals.txt?rev=795352&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/goals.txt (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/goals.txt Sat Jul 18 12:16:54 2009
@@ -0,0 +1 @@
+clean javadoc:javadoc
\ No newline at end of file

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/goals.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/goals.txt
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module1/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module1/pom.xml?rev=795352&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module1/pom.xml (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module1/pom.xml Sat Jul 18 12:16:54 2009
@@ -0,0 +1,35 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.maven.plugins.maven-javadoc-plugin.it</groupId>
+    <artifactId>linkoffline-test-parent</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <relativePath>../pom.xml</relativePath>
+  </parent>
+
+  <groupId>org.apache.maven.plugins.maven-javadoc-plugin.it</groupId>
+  <artifactId>linkoffline-test-module1</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <url>http://myhost/module1</url>
+</project>
\ No newline at end of file

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module1/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module1/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module1/src/main/java/com/mycompany/app/App.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module1/src/main/java/com/mycompany/app/App.java?rev=795352&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module1/src/main/java/com/mycompany/app/App.java (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module1/src/main/java/com/mycompany/app/App.java Sat Jul 18 12:16:54 2009
@@ -0,0 +1,36 @@
+package com.mycompany.app;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Hello world!
+ */
+public class App
+{
+    /**
+     * Test an offline link to module2: {@link com.mycompany.app2.App2}
+     *
+     * @param args could be null
+     */
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello World!" );
+    }
+}

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module1/src/main/java/com/mycompany/app/App.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module1/src/main/java/com/mycompany/app/App.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module2/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module2/pom.xml?rev=795352&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module2/pom.xml (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module2/pom.xml Sat Jul 18 12:16:54 2009
@@ -0,0 +1,35 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.maven.plugins.maven-javadoc-plugin.it</groupId>
+    <artifactId>linkoffline-test-parent</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <relativePath>../pom.xml</relativePath>
+  </parent>
+
+  <groupId>org.apache.maven.plugins.maven-javadoc-plugin.it</groupId>
+  <artifactId>linkoffline-test-module2</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <url>http://myhost/module2</url>
+</project>

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module2/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module2/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module2/src/main/java/com/mycompany/app2/App2.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module2/src/main/java/com/mycompany/app2/App2.java?rev=795352&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module2/src/main/java/com/mycompany/app2/App2.java (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module2/src/main/java/com/mycompany/app2/App2.java Sat Jul 18 12:16:54 2009
@@ -0,0 +1,36 @@
+package com.mycompany.app2;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Hello world!
+ */
+public class App2
+{
+    /**
+     * Test an offline link to module1: {@link com.mycompany.app.App}
+     *
+     * @param args could be null
+     */
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello World!" );
+    }
+}

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module2/src/main/java/com/mycompany/app2/App2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/module2/src/main/java/com/mycompany/app2/App2.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/pom.xml?rev=795352&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/pom.xml (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/pom.xml Sat Jul 18 12:16:54 2009
@@ -0,0 +1,60 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins.maven-javadoc-plugin.it</groupId>
+  <artifactId>linkoffline-test-parent</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <url>http://myhost/parent</url>
+
+  <modules>
+    <module>module1</module>
+    <module>module2</module>
+  </modules>
+  
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <artifactId>maven-javadoc-plugin</artifactId>
+          <version>@pom.version@</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <configuration>
+          <debug>true</debug>
+          <failOnError>true</failOnError>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+</project>

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/verify.bsh?rev=795352&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/verify.bsh (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/it/MJAVADOC-97/verify.bsh Sat Jul 18 12:16:54 2009
@@ -0,0 +1,109 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.*;
+
+boolean result = true;
+
+try
+{
+    File apidocs1 = new File( basedir, "module1/target/site/apidocs" );
+    if ( !apidocs1.exists() || !apidocs1.isDirectory() )
+    {
+        System.err.println( apidocs1.getAbsolutePath() + " dir is missing or a directory." );
+        return false;
+    }
+    File apidocs2 = new File( basedir, "module2/target/site/apidocs" );
+    if ( !apidocs2.exists() || !apidocs2.isDirectory() )
+    {
+        System.err.println( apidocs2.getAbsolutePath() + " dir is missing or a directory." );
+        return false;
+    }
+
+    File options1 = new File( apidocs1, "options" );
+    if ( !options1.exists() || !options1.isFile() )
+    {
+        System.err.println( options1.getAbsolutePath() + " file is missing or not a file." );
+        return false;
+    }
+    File options2 = new File( apidocs1, "options" );
+    if ( !options2.exists() || !options2.isFile() )
+    {
+        System.err.println( options2.getAbsolutePath() + " file is missing or not a file." );
+        return false;
+    }
+
+    String strTmp = "";
+    String contentOptions1 = "";
+    BufferedReader in = new BufferedReader( new FileReader( options1 ) );
+    try
+    {
+        while ( ( strTmp = in.readLine() ) != null )
+        {
+            contentOptions1 = contentOptions1 + " " + strTmp;
+        }
+    }
+    finally
+    {
+        in.close();
+    }
+    String contentOptions2 = "";
+    BufferedReader in = new BufferedReader( new FileReader( options2 ) );
+    try
+    {
+        while ( ( strTmp = in.readLine() ) != null )
+        {
+            contentOptions2 = contentOptions2 + " " + strTmp;
+        }
+    }
+    finally
+    {
+        in.close();
+    }
+
+    if ( contentOptions1.indexOf( "-linkoffline" ) == -1 )
+    {
+        System.err.println( "-linkoffline not added." );
+        return false;
+    }
+    if ( contentOptions1.indexOf( apidocs2.getAbsolutePath().replaceAll( "\\\\", "/" ) ) == -1 )
+    {
+        System.err.println( apidocs2.getAbsolutePath().replaceAll( "\\\\", "/" ) + " not added." );
+        return false;
+    }
+
+    if ( contentOptions2.indexOf( "-linkoffline" ) == -1 )
+    {
+        System.err.println( "-linkoffline not added." );
+        return false;
+    }
+    if ( contentOptions2.indexOf( apidocs1.getAbsolutePath().replaceAll( "\\\\", "/" ) ) == -1 )
+    {
+        System.err.println( apidocs1.getAbsolutePath().replaceAll( "\\\\", "/" ) + " not added." );
+        return false;
+    }
+}
+catch( RuntimeException e )
+{
+    e.printStackTrace();
+    return false;
+}
+
+return result;

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractFixJavadocMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractFixJavadocMojo.java?rev=795352&r1=795351&r2=795352&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractFixJavadocMojo.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractFixJavadocMojo.java Sat Jul 18 12:16:54 2009
@@ -22,14 +22,11 @@
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.PrintStream;
 import java.io.Reader;
 import java.io.StringReader;
 import java.io.StringWriter;
-import java.io.UnsupportedEncodingException;
 import java.io.Writer;
 import java.lang.reflect.AccessibleObject;
 import java.lang.reflect.Method;
@@ -57,21 +54,12 @@
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.settings.Settings;
-import org.apache.maven.shared.invoker.DefaultInvocationRequest;
-import org.apache.maven.shared.invoker.DefaultInvoker;
-import org.apache.maven.shared.invoker.InvocationOutputHandler;
-import org.apache.maven.shared.invoker.InvocationRequest;
-import org.apache.maven.shared.invoker.InvocationResult;
-import org.apache.maven.shared.invoker.Invoker;
-import org.apache.maven.shared.invoker.MavenInvocationException;
-import org.apache.maven.shared.invoker.PrintStreamHandler;
 import org.codehaus.plexus.components.interactivity.InputHandler;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.WriterFactory;
-import org.codehaus.plexus.util.cli.CommandLineUtils;
 
 import com.thoughtworks.qdox.JavaDocBuilder;
 import com.thoughtworks.qdox.model.AbstractInheritableJavaEntity;
@@ -596,77 +584,18 @@
             return;
         }
 
-        String mavenHome = getMavenHome();
-        if ( StringUtils.isEmpty( getMavenHome() ) )
-        {
-            getLog().info( "Cannot invoke Maven because no Maven home is defined, Clirr is ignored." );
-            return;
-        }
-
-        Invoker invoker = new DefaultInvoker();
-        invoker.setMavenHome( new File( mavenHome ) );
-
-        InvocationRequest request = new DefaultInvocationRequest();
-        request.setBaseDirectory( project.getBasedir() );
-        request.setPomFile( project.getFile() );
-
-        File invokerLogFile = new File( project.getBuild().getDirectory(), "invoker-clirr-maven-plugin.txt" );
-        PrintStream ps;
-        try
-        {
-            ps = new PrintStream( new FileOutputStream( invokerLogFile ), true, "UTF-8" );
-        }
-        catch ( FileNotFoundException e )
-        {
-            getLog().error( "FileNotFoundException: " + e.getMessage() + ". Using System.out to log the invoker." );
-            ps = System.out;
-        }
-        catch ( UnsupportedEncodingException e )
-        {
-            getLog().error( "UnsupportedEncodingException: " + e.getMessage() + ". Using System.out to log the invoker." );
-            ps = System.out;
-        }
-
-        InvocationOutputHandler outputHandler = new PrintStreamHandler( ps, false );
-        request.setOutputHandler( outputHandler );
-        request.setDebug( true );
-
         String clirrGoal = getFullClirrGoal();
-        request.setGoals( Collections.singletonList( clirrGoal ) );
 
         // http://mojo.codehaus.org/clirr-maven-plugin/check-mojo.html
         File clirrTextOutputFile = new File( project.getBuild().getDirectory(), "clirr.txt" );
-        Properties prop = new Properties();
-        prop.put( "textOutputFile", clirrTextOutputFile.getAbsolutePath() );
-        prop.put( "comparisonVersion", comparisonVersion );
-        prop.put( "failOnError", "false" );
-        request.setProperties( prop );
+        Properties properties = new Properties();
+        properties.put( "textOutputFile", clirrTextOutputFile.getAbsolutePath() );
+        properties.put( "comparisonVersion", comparisonVersion );
+        properties.put( "failOnError", "false" );
 
-        InvocationResult result;
-        try
-        {
-            getLog().debug( "Invoking Maven for the goal: " + clirrGoal );
-            result = invoker.execute( request );
-        }
-        catch ( MavenInvocationException e )
-        {
-            if ( getLog().isDebugEnabled() )
-            {
-                getLog().error( "MavenInvocationException: " + e.getMessage(), e );
-            }
-            else
-            {
-                getLog().error( "MavenInvocationException: " + e.getMessage() );
-            }
-            getLog().error( "Error when invoking Maven, consult the invoker log. Clirr is ignored." );
-            return;
-        }
-
-        if ( result.getExitCode() != 0 )
-        {
-            getLog().error( "Error when invoking Maven, consult the invoker log. Clirr is ignored." );
-            return;
-        }
+        File invokerLogFile = new File( project.getBuild().getDirectory(), "invoker-clirr-maven-plugin.txt" );
+        JavadocUtil.invokeMaven( getLog(), project.getFile(), Collections.singletonList( clirrGoal ), properties,
+                                 invokerLogFile );
 
         try
         {
@@ -742,6 +671,7 @@
         {
             IOUtil.close( resourceAsStream );
         }
+
         sb.append( clirrVersion ).append( ":" );
         sb.append( CLIRR_MAVEN_PLUGIN_GOAL );
 
@@ -2936,28 +2866,6 @@
     }
 
     /**
-     * @return the maven home defined in the "maven.home" system property or defined in M2_HOME system env variables
-     * or null if never setted.
-     */
-    private static String getMavenHome()
-    {
-        String mavenHome = System.getProperty( "maven.home" );
-        if ( mavenHome == null )
-        {
-            try
-            {
-                mavenHome = CommandLineUtils.getSystemEnvVars().getProperty( "M2_HOME" );
-            }
-            catch ( IOException e )
-            {
-                // nop
-            }
-        }
-
-        return mavenHome;
-    }
-
-    /**
      * Default comment for class.
      *
      * @param javaClass not null

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=795352&r1=795351&r2=795352&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 Sat Jul 18 12:16:54 2009
@@ -21,6 +21,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -85,12 +86,14 @@
 import org.codehaus.plexus.archiver.manager.ArchiverManager;
 import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
 import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.cli.CommandLineException;
 import org.codehaus.plexus.util.cli.CommandLineUtils;
 import org.codehaus.plexus.util.cli.Commandline;
 import org.codehaus.plexus.util.cli.DefaultConsumer;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
 
 /**
  * Base class with majority of Javadoc functionalities.
@@ -1076,6 +1079,51 @@
      * &lt;/offlineLinks&gt;
      * </pre>
      * <br/>
+     * <b>Note</b>: By default, if {@link #reactorProjects} is defined in a non-aggregator way, it generates default offline links
+     * between modules based on the defined project's urls. For instance, if a parent project has two projects
+     * <code>module1</code> and <code>module2</code>, the <code>-linkoffline</code> will be:
+     * <br/>
+     * <table>
+     * <tr>
+     *   <th>Module project</th>
+     *   <th>Option for '-linkoffline'</th>
+     * </tr>
+     * <tr>
+     *   <td>
+     *     <pre>
+     * &lt;project&gt;
+     *   &lt;artifactId&gt;<b>module1</b>&lt;/artifactId&gt;
+     *   &lt;url&gt;http://myhost/<b>module1</b>&lt;/url&gt;
+     *   ...
+     * &lt;/project&gt;
+     *     </pre>
+     *   </td>
+     *   <td>
+     *     <pre>
+     * -linkoffline
+     * 'http://myhost/<b>module2</b>/apidocs' '/absolute/path/to/<b>module2</b>/target/site/apidocs'
+     *     </pre>
+     *   </td>
+     * </tr>
+     * <tr>
+     *   <td>
+     *     <pre>
+     * &lt;project&gt;
+     *   &lt;artifactId&gt;<b>module2</b>&lt;/artifactId&gt;
+     *   &lt;url&gt;http://myhost/<b>module2</b>&lt;/url&gt;
+     *   ...
+     * &lt;/project&gt;
+     *     </pre>
+     *   </td>
+     *   <td>
+     *     <pre>
+     * -linkoffline
+     * 'http://myhost/<b>module1</b>/apidocs' '/absolute/path/to/<b>module1</b>/target/site/apidocs'
+     *     </pre>
+     *   </td>
+     * </tr>
+     * </table>
+     * <br/>
      * See <a href="./apidocs/org/apache/maven/plugin/javadoc/options/OfflineLink.html">Javadoc</a>.
      * <br/>
      *
@@ -2994,9 +3042,11 @@
     }
 
     /**
-     * Convenience method to process offlineLink values as individual -linkoffline javadoc options
+     * Convenience method to process {@link #offlineLinks} values as individual <code>-linkoffline</code>
+     * javadoc options.
      *
      * @param arguments a list of arguments, not null
+     * @see #offlineLinks
      */
     private void addLinkofflineArguments( List arguments )
     {
@@ -3007,23 +3057,58 @@
         {
             String javadocDirRelative = PathUtils.toRelative( project.getBasedir(), getOutputDirectory() );
 
+            int i = 0;
             for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
             {
                 MavenProject p = (MavenProject) it.next();
 
-                // don't add projects that have not built yet.
+                if ( p.getPackaging().equals( "pom" ) )
+                {
+                    continue;
+                }
+
                 if ( p.getId().equals( project.getId() ) )
                 {
-                    break;
+                    continue;
                 }
 
+                File location = new File( p.getBasedir(), javadocDirRelative );
                 if ( p.getUrl() != null )
                 {
-                    String url = p.getUrl() + "/apidocs";
-                    File location = new File( p.getBasedir(), javadocDirRelative );
+                    if ( !location.exists() )
+                    {
+                        String javadocGoal = getFullJavadocGoal();
+                        getLog().info(
+                                       "The goal '" + javadocGoal
+                                           + "' has not be previously called for the project: '" + p.getId()
+                                           + "'. Trying to invoke it..." );
+
+                        File invokerLogFile =
+                            new File( project.getBuild().getDirectory(), "invoker-maven-javadoc-plugin-" + i
+                                + ".txt" );
+                        JavadocUtil.invokeMaven( getLog(), p.getFile(), Collections.singletonList( javadocGoal ),
+                                                 null, invokerLogFile );
+                    }
 
                     if ( location.exists() )
                     {
+                        String destDir = "apidocs"; // see JavadocReport#destDir
+
+                        Plugin javadocPlugin =
+                            (Plugin) project.getBuild().getPluginsAsMap()
+                                            .get( "org.apache.maven.plugins:maven-javadoc-plugin" );
+                        if ( javadocPlugin != null )
+                        {
+                            Xpp3Dom xpp3Dom = (Xpp3Dom) javadocPlugin.getConfiguration();
+                            if ( xpp3Dom != null && xpp3Dom.getChild( "destDir" ) != null
+                                && StringUtils.isNotEmpty( xpp3Dom.getChild( "destDir" ).getValue() ) )
+                            {
+                                destDir = xpp3Dom.getChild( "destDir" ).getValue();
+                            }
+                        }
+
+                        String url = p.getUrl() + "/" + destDir;
+
                         OfflineLink ol = new OfflineLink();
                         ol.setUrl( url );
                         ol.setLocation( location.getAbsolutePath() );
@@ -3031,6 +3116,8 @@
                         offlineLinksList.add( ol );
                     }
                 }
+
+                i++;
             }
         }
 
@@ -4254,4 +4341,60 @@
 
         return javadocClassLoader.getResource( resource );
     }
+
+    /**
+     * Load the plugin pom.properties to get the current plugin version.
+     *
+     * @return <code>org.apache.maven.plugins:maven-javadoc-plugin:CURRENT_VERSION:javadoc</code>
+     */
+    private String getFullJavadocGoal()
+    {
+        String javadocVersion = null;
+        InputStream resourceAsStream = null;
+        try
+        {
+            String resource =
+                "META-INF/maven/org.apache.maven.plugins/maven-javadoc-plugin/pom.properties";
+            resourceAsStream = AbstractJavadocMojo.class.getClassLoader().getResourceAsStream( resource );
+
+            if ( resourceAsStream != null )
+            {
+                Properties properties = new Properties();
+                properties.load( resourceAsStream );
+
+                if ( StringUtils.isNotEmpty( properties.getProperty( "version" ) ) )
+                {
+                    javadocVersion = properties.getProperty( "version" );
+                }
+            }
+        }
+        catch ( IOException e )
+        {
+            // nop
+        }
+        finally
+        {
+            IOUtil.close( resourceAsStream );
+        }
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "org.apache.maven.plugins" ).append( ":" );
+        sb.append( "maven-javadoc-plugin" ).append( ":" );
+        if ( StringUtils.isNotEmpty( javadocVersion ) )
+        {
+            sb.append( javadocVersion ).append( ":" );
+        }
+
+        if ( TestJavadocReport.class.isAssignableFrom( getClass() ))
+        {
+            sb.append( "test-javadoc" );
+        }
+        else
+        {
+            sb.append( "javadoc" );
+        }
+
+        return sb.toString();
+    }
 }

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocUtil.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocUtil.java?rev=795352&r1=795351&r2=795352&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocUtil.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocUtil.java Sat Jul 18 12:16:54 2009
@@ -28,6 +28,8 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
+import java.io.PrintStream;
+import java.io.Reader;
 import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Modifier;
 import java.net.URL;
@@ -37,6 +39,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
+import java.util.Properties;
 import java.util.Set;
 import java.util.StringTokenizer;
 import java.util.jar.JarEntry;
@@ -49,12 +52,23 @@
 import org.apache.commons.httpclient.UsernamePasswordCredentials;
 import org.apache.commons.httpclient.auth.AuthScope;
 import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.lang.SystemUtils;
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.settings.Proxy;
 import org.apache.maven.settings.Settings;
+import org.apache.maven.shared.invoker.DefaultInvocationRequest;
+import org.apache.maven.shared.invoker.DefaultInvoker;
+import org.apache.maven.shared.invoker.InvocationOutputHandler;
+import org.apache.maven.shared.invoker.InvocationRequest;
+import org.apache.maven.shared.invoker.InvocationResult;
+import org.apache.maven.shared.invoker.Invoker;
+import org.apache.maven.shared.invoker.MavenInvocationException;
+import org.apache.maven.shared.invoker.PrintStreamHandler;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.cli.CommandLineException;
 import org.codehaus.plexus.util.cli.CommandLineUtils;
@@ -933,6 +947,160 @@
         }
     }
 
+    /**
+     * Invoke Maven for the given project file with a list of goals and properties, the output will be in the
+     * invokerlog file.
+     * <br/>
+     * <b>Note</b>: the Maven Home should be defined in the <code>maven.home</code> Java system property or defined in
+     * <code>M2_HOME</code> system env variables.
+     *
+     * @param log a logger could be null.
+     * @param project a not null project file.
+     * @param goals a not null goals list.
+     * @param properties the properties for the goals, could be null.
+     * @param invokerLog the log file where the invoker will be written, if null using <code>System.out</code>.
+     * @since 2.6
+     */
+    protected static void invokeMaven( Log log, File projectFile, List goals, Properties properties,
+                                       File invokerLog )
+    {
+        if ( projectFile == null )
+        {
+            throw new IllegalArgumentException( "projectFile should be not null." );
+        }
+        if ( !projectFile.isFile() )
+        {
+            throw new IllegalArgumentException( projectFile.getAbsolutePath() + " is not a file." );
+        }
+        if ( goals == null || goals.size() == 0 )
+        {
+            throw new IllegalArgumentException( "goals should be not empty." );
+        }
+
+        String mavenHome = getMavenHome( log );
+        if ( StringUtils.isEmpty( mavenHome ) )
+        {
+            String msg =
+                "Could NOT invoke Maven because no Maven Home is defined. You need to have set the M2_HOME "
+                    + "system env variable or a maven.home Java system properties.";
+            if ( log != null )
+            {
+                log.error( msg );
+            }
+            else
+            {
+                System.err.println( msg );
+            }
+            return;
+        }
+
+        Invoker invoker = new DefaultInvoker();
+        invoker.setMavenHome( new File( mavenHome ) );
+
+        InvocationRequest request = new DefaultInvocationRequest();
+        request.setBaseDirectory( projectFile.getParentFile() );
+        request.setPomFile( projectFile );
+
+        if ( log != null )
+        {
+            request.setDebug( log.isDebugEnabled() );
+        }
+        else
+        {
+            request.setDebug( true );
+        }
+        request.setGoals( goals );
+        if ( properties != null )
+        {
+            request.setProperties( properties );
+        }
+
+        InvocationResult result;
+        try
+        {
+            if ( log != null )
+            {
+                log.debug( "Invoking Maven for the goals: " + goals + " with properties=" + properties );
+            }
+            result = invoke( log, invoker, request, invokerLog, goals, properties, null );
+        }
+        catch ( MavenInvocationException e )
+        {
+            if ( log != null )
+            {
+                if ( log.isDebugEnabled() )
+                {
+                    log.error( "MavenInvocationException: " + e.getMessage(), e );
+                }
+                else
+                {
+                    log.error( "MavenInvocationException: " + e.getMessage() );
+                }
+                log.error( "Error when invoking Maven, consult the invoker log." );
+            }
+            return;
+        }
+
+        String invokerLogContent = null;
+        Reader reader = null;
+        try
+        {
+            reader = ReaderFactory.newReader( invokerLog, "UTF-8" );
+            invokerLogContent = IOUtil.toString( reader );
+        }
+        catch ( IOException e )
+        {
+            if ( log != null )
+            {
+                log.error( "IOException: " + e.getMessage() );
+            }
+        }
+        finally
+        {
+            IOUtil.close( reader );
+        }
+
+        if ( invokerLogContent != null
+            && invokerLogContent.indexOf( "Error occurred during initialization of VM" ) != -1 )
+        {
+            if ( log != null )
+            {
+                log.info( "Error occurred during initialization of VM, try to use an empty MAVEN_OPTS." );
+
+                log.debug( "Reinvoking Maven for the goals: " + goals + " with an empty MAVEN_OPTS" );
+            }
+            try
+            {
+                result = invoke( log, invoker, request, invokerLog, goals, properties, "" );
+            }
+            catch ( MavenInvocationException e )
+            {
+                if ( log != null )
+                {
+                    if ( log.isDebugEnabled() )
+                    {
+                        log.error( "MavenInvocationException: " + e.getMessage(), e );
+                    }
+                    else
+                    {
+                        log.error( "MavenInvocationException: " + e.getMessage() );
+                    }
+                    log.error( "Error when reinvoking Maven, consult the invoker log." );
+                }
+                return;
+            }
+        }
+
+        if ( result.getExitCode() != 0 )
+        {
+            if ( log != null )
+            {
+                log.error( "Error when invoking Maven, consult the invoker log file: "
+                    + invokerLog.getAbsolutePath() );
+            }
+        }
+    }
+
     // ----------------------------------------------------------------------
     // private methods
     // ----------------------------------------------------------------------
@@ -982,4 +1150,217 @@
 
         return classes;
     }
+
+    /**
+     * @param log could be null
+     * @param invoker not null
+     * @param request not null
+     * @param invokerLog not null
+     * @param goals not null
+     * @param properties could be null
+     * @param mavenOpts could be null
+     * @return the invocation result
+     * @throws MavenInvocationException if any
+     * @since 2.6
+     */
+    private static InvocationResult invoke( Log log, Invoker invoker, InvocationRequest request, File invokerLog,
+                                            List goals, Properties properties, String mavenOpts )
+        throws MavenInvocationException
+    {
+        PrintStream ps;
+        OutputStream os = null;
+        if ( invokerLog != null )
+        {
+            log.debug( "Using "+ invokerLog.getAbsolutePath() + " to log the invoker" );
+
+            try
+            {
+                if ( !invokerLog.exists() )
+                {
+                    invokerLog.getParentFile().mkdirs();
+                }
+                os = new FileOutputStream( invokerLog );
+                ps = new PrintStream( os, true, "UTF-8" );
+            }
+            catch ( FileNotFoundException e )
+            {
+                if ( log != null )
+                {
+                    log.error( "FileNotFoundException: " + e.getMessage() + ". Using System.out to log the invoker." );
+                }
+                ps = System.out;
+            }
+            catch ( UnsupportedEncodingException e )
+            {
+                if ( log != null )
+                {
+                    log.error( "UnsupportedEncodingException: " + e.getMessage()
+                        + ". Using System.out to log the invoker." );
+                }
+                ps = System.out;
+            }
+        }
+        else
+        {
+            log.debug( "Using System.out to log the invoker." );
+
+            ps = System.out;
+        }
+
+        if ( mavenOpts != null )
+        {
+            request.setMavenOpts( mavenOpts );
+        }
+
+        InvocationOutputHandler outputHandler = new PrintStreamHandler( ps, false );
+        request.setOutputHandler( outputHandler );
+
+        outputHandler.consumeLine( "Invoking Maven for the goals: " + goals + " with properties=" + properties );
+        outputHandler.consumeLine( "" );
+        outputHandler.consumeLine( "M2_HOME=" + getMavenHome( log ) );
+        outputHandler.consumeLine( "MAVEN_OPTS=" + getMavenOpts( log ) );
+        outputHandler.consumeLine( "JAVA_HOME=" + getJavaHome( log ) );
+        outputHandler.consumeLine( "JAVA_OPTS=" + getJavaOpts( log ) );
+        outputHandler.consumeLine( "" );
+
+        try
+        {
+            return invoker.execute( request );
+        }
+        finally
+        {
+            IOUtil.close( os );
+            ps = null;
+        }
+    }
+
+    /**
+     * @param log a logger could be null
+     * @return the Maven home defined in the <code>maven.home</code> system property or defined
+     * in <code>M2_HOME</code> system env variables or null if never setted.
+     * @since 2.6
+     */
+    private static String getMavenHome( Log log )
+    {
+        String mavenHome = System.getProperty( "maven.home" );
+        if ( mavenHome == null )
+        {
+            try
+            {
+                mavenHome = CommandLineUtils.getSystemEnvVars().getProperty( "M2_HOME" );
+            }
+            catch ( IOException e )
+            {
+                if ( log != null )
+                {
+                    log.debug( "IOException: " + e.getMessage() );
+                }
+            }
+        }
+
+        File m2Home = new File( mavenHome );
+        if ( !m2Home.exists() )
+        {
+            if ( log != null )
+            {
+                log
+                   .error( "Cannot find Maven application directory. Either specify \'maven.home\' system property, or "
+                       + "M2_HOME environment variable." );
+            }
+        }
+
+        return mavenHome;
+    }
+
+    /**
+     * @param log a logger could be null
+     * @return the <code>MAVEN_OPTS</code> env variable value
+     * @since 2.6
+     */
+    private static String getMavenOpts( Log log )
+    {
+        String mavenOpts = null;
+        try
+        {
+            mavenOpts = CommandLineUtils.getSystemEnvVars().getProperty( "MAVEN_OPTS" );
+        }
+        catch ( IOException e )
+        {
+            if ( log != null )
+            {
+                log.debug( "IOException: " + e.getMessage() );
+            }
+        }
+
+        return mavenOpts;
+    }
+
+    /**
+     * @param log a logger could be null
+     * @return the <code>JAVA_HOME</code> from System.getProperty( "java.home" )
+     * By default, <code>System.getProperty( "java.home" ) = JRE_HOME</code> and <code>JRE_HOME</code>
+     * should be in the <code>JDK_HOME</code>
+     * @since 2.6
+     */
+    private static File getJavaHome( Log log )
+    {
+        File javaHome;
+        if ( SystemUtils.IS_OS_MAC_OSX )
+        {
+            javaHome = SystemUtils.getJavaHome();
+        }
+        else
+        {
+            javaHome = new File( SystemUtils.getJavaHome(), ".." );
+        }
+
+        if ( javaHome == null || !javaHome.exists() )
+        {
+            try
+            {
+                javaHome = new File( CommandLineUtils.getSystemEnvVars().getProperty( "JAVA_HOME" ) );
+            }
+            catch ( IOException e )
+            {
+                if ( log != null )
+                {
+                    log.debug( "IOException: " + e.getMessage() );
+                }
+            }
+        }
+
+        if ( javaHome == null || !javaHome.exists() )
+        {
+            if ( log != null )
+            {
+                log.error( "Cannot find Java application directory. Either specify \'java.home\' system property, or "
+                    + "JAVA_HOME environment variable." );
+            }
+        }
+
+        return javaHome;
+    }
+
+    /**
+     * @param log a logger could be null
+     * @return the <code>JAVA_OPTS</code> env variable value
+     * @since 2.6
+     */
+    private static String getJavaOpts( Log log )
+    {
+        String javaOpts= null;
+        try
+        {
+            javaOpts = CommandLineUtils.getSystemEnvVars().getProperty( "JAVA_OPTS" );
+        }
+        catch ( IOException e )
+        {
+            if ( log != null )
+            {
+                log.debug( "IOException: " + e.getMessage() );
+            }
+        }
+
+        return javaOpts;
+    }
 }

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/site/fml/faq.fml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/site/fml/faq.fml?rev=795352&r1=795351&r2=795352&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/site/fml/faq.fml (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/site/fml/faq.fml Sat Jul 18 12:16:54 2009
@@ -19,7 +19,11 @@
 under the License.
 -->
 
-<faqs id="FAQ" title="Frequently Asked Questions">
+
+<faqs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns="http://maven.apache.org/FML/1.0"
+  xsi:schemaLocation="http://maven.apache.org/FML/1.0 http://maven.apache.org/xsd/fml-1.0.xsd"
+  id="FAQ" title="Frequently Asked Questions">
   <part id="General">
     <faq id="What are the Javadoc options supported by the Maven Javadoc Plugin">
       <question>What are the Javadoc options supported by the Maven Javadoc Plugin?</question>
@@ -251,11 +255,11 @@
         <p>
           You need to configure the <i>&lt;links/&gt;</i> parameter. Also, you need to correctly write references in
           your Javadoc, i.e.:
-          <ul>
-            <li><code>@see MyMojo</code> or <code>{@link MyMojo}</code> will <b>NOT work</b>.</li>
-            <li><code>@see com.mycompany.plugin.myplugin.MyMojo</code> or <code>{@link com.mycompany.myplugin.MyMojo}</code> will <b>work</b>.</li>
-          </ul>
         </p>
+        <ul>
+          <li><code>@see MyMojo</code> or <code>{@link MyMojo}</code> will <b>NOT work</b>.</li>
+          <li><code>@see com.mycompany.plugin.myplugin.MyMojo</code> or <code>{@link com.mycompany.myplugin.MyMojo}</code> will <b>work</b>.</li>
+        </ul>
       </answer>
     </faq>
     <faq id="On Windows with Sun JDK, why javadoc:javadoc goal blows up due to an IllegalArgumentException in sun.net.www.ParseUtil.decode()">
@@ -265,8 +269,9 @@
           You are on Windows XP with Sun JDK 5 or JDK 6 freshly installed, and when you run <i>mvn javadoc:javadoc</i>,
           you are stick by an <i>sun.net.www.ParseUtil.decode()</i> exception like this
           <a href="javascript:;" onclick="toggleException( '_6219854' );" style="cursor: pointer;vertical-align:text-bottom;">one</a>.
-          <div id="_6219854" style="display:none">
-            <source>
+        </p>
+        <div id="_6219854" style="display:none">
+          <source>
 ...
 [INFO] ------------------------------------------------------------------------
 [ERROR] BUILD ERROR
@@ -347,8 +352,7 @@
 
   Command line was:C:\Java\jdk1.6.0_03\jre\..\bin\javadoc.exe @options @packages
   ...</source>
-            </div>
-        </p>
+        </div>
         <p>
           Your <i>CLASSPATH</i> environement variable is probably corrupted, i.e. something like:
           <source>CLASSPATH=.;C:\Java\jdk1.6.0_03\jre\lib\ext\QTJava.zip;%JAVAHOME%</source>
@@ -387,15 +391,26 @@
       <answer>
         <p>
           By default, these parameters have the following values:
-          <dl>
-            <dt><code>encoding</code></dt>
-            <dd>Value of <code>${project.build.sourceEncoding}</code> property or the value of the
-              <code>file.encoding</code> system property if not specified.</dd>
-            <dt><code>docencoding</code></dt>
-            <dd>Value of <code>${project.reporting.outputEncoding}</code> property or <code>UTF-8</code> if not specified.</dd>
-            <dt><code>charset</code></dt>
-            <dd>Value of <code>docencoding</code> parameter if not specified.</dd>
-          </dl>
+        </p>
+        <dl>
+          <dt><code>encoding</code></dt>
+          <dd>Value of <code>${project.build.sourceEncoding}</code> property or the value of the
+            <code>file.encoding</code> system property if not specified.</dd>
+          <dt><code>docencoding</code></dt>
+          <dd>Value of <code>${project.reporting.outputEncoding}</code> property or <code>UTF-8</code> if not specified.</dd>
+          <dt><code>charset</code></dt>
+          <dd>Value of <code>docencoding</code> parameter if not specified.</dd>
+        </dl>
+      </answer>
+    </faq>
+    <faq id="How to link the multi-modules Javadoc directories">
+      <question>How to link the multi-modules Javadoc directories?</question>
+      <answer>
+        <p>
+          By default, the Javadoc Plugin uses
+          <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javadoc.html#linkoffline">linkoffline</a>
+          to link the generated multi-modules Javadoc directories together. For more information about the default
+          values, refer you to the Javadoc Plugin <a href="./javadoc-mojo.html#offlineLinks">offlineLinks</a>.
         </p>
       </answer>
     </faq>

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/FixJavadocMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/FixJavadocMojoTest.java?rev=795352&r1=795351&r2=795352&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/FixJavadocMojoTest.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/FixJavadocMojoTest.java Sat Jul 18 12:16:54 2009
@@ -19,10 +19,8 @@
  * under the License.
  */
 
-import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
-import java.io.PrintStream;
 import java.io.Reader;
 import java.io.StringReader;
 import java.util.ArrayList;
@@ -32,20 +30,12 @@
 import junitx.util.PrivateAccessor;
 
 import org.apache.commons.lang.SystemUtils;
+import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.shared.invoker.DefaultInvocationRequest;
-import org.apache.maven.shared.invoker.DefaultInvoker;
-import org.apache.maven.shared.invoker.InvocationOutputHandler;
-import org.apache.maven.shared.invoker.InvocationRequest;
-import org.apache.maven.shared.invoker.InvocationResult;
-import org.apache.maven.shared.invoker.Invoker;
-import org.apache.maven.shared.invoker.MavenInvocationException;
-import org.apache.maven.shared.invoker.PrintStreamHandler;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.cli.CommandLineUtils;
 
 import com.thoughtworks.qdox.JavaDocBuilder;
 import com.thoughtworks.qdox.model.AbstractInheritableJavaEntity;
@@ -64,19 +54,6 @@
     /** The vm line separator */
     private static final String EOL = System.getProperty( "line.separator" );
 
-    /** The M2_HOME env variable */
-    private static final File M2_HOME;
-
-    /** The M2_HOME env variable */
-    private static final File JAVA_HOME;
-
-    static
-    {
-        M2_HOME = getM2Home();
-
-        JAVA_HOME = getJavaHome();
-    }
-
     /**
      * @throws Exception if any
      */
@@ -536,12 +513,13 @@
         File testPom = new File( testPomBasedir, "pom.xml" );
         assertTrue( testPom.getAbsolutePath() + " should exist", testPom.exists() );
 
+        FixJavadocMojo mojo = (FixJavadocMojo) lookupMojo( "fix", testPom );
+        assertNotNull( mojo );
+
         // compile the test project
-        invokeCompileGoal( testPom );
+        invokeCompileGoal( testPom, mojo.getLog() );
         assertTrue( new File( testPomBasedir, "target/classes" ).exists() );
 
-        FixJavadocMojo mojo = (FixJavadocMojo) lookupMojo( "fix", testPom );
-        assertNotNull( mojo );
         mojo.execute();
 
         File expectedDir = new File( testPomBasedir, "expected/src/main/java/fix/test" );
@@ -560,58 +538,17 @@
     /**
      * Invoke the compilation on the given pom file.
      *
-     * @param testPom
+     * @param testPom not null
+     * @param log not null
      */
-    private void invokeCompileGoal( File testPom )
+    private void invokeCompileGoal( File testPom, Log log )
     {
-        Invoker invoker = new DefaultInvoker();
-        invoker.setMavenHome( M2_HOME );
-
-        ByteArrayOutputStream invokerLog = new ByteArrayOutputStream();
-        InvocationOutputHandler outputHandler = new PrintStreamHandler( new PrintStream( invokerLog ), false );
-
-        outputHandler.consumeLine( "Invoke Maven" );
-        outputHandler.consumeLine( "M2_HOME=" + M2_HOME );
-        outputHandler.consumeLine( "JAVA_HOME=" + JAVA_HOME );
-
-        InvocationRequest request = new DefaultInvocationRequest();
-        request.setBaseDirectory( testPom.getParentFile() );
-        request.setPomFile( testPom );
-        request.setOutputHandler( outputHandler );
-        request.setDebug( true );
-        request.setJavaHome( JAVA_HOME );
-        request.setMavenOpts( "-Xms256m -Xmx256m" );
-
         List goals = new ArrayList();
         goals.add( "clean" );
         goals.add( "compile" );
 
-        request.setGoals( goals );
-
-        try
-        {
-            InvocationResult result = invoker.execute( request );
-            if ( result.getExitCode() != 0 )
-            {
-                StringBuffer msg = new StringBuffer();
-                msg.append( "Ouput from invoker:" ).append( "\n\n" );
-                msg.append( invokerLog ).append( "\n\n" );
-
-                getContainer().getLogger().error( msg.toString() );
-
-                fail( "Error when invoking Maven, see invoker log above" );
-            }
-        }
-        catch ( MavenInvocationException e )
-        {
-            StringBuffer msg = new StringBuffer();
-            msg.append( "Ouput from invoker:" ).append( "\n\n" );
-            msg.append( invokerLog ).append( "\n\n" );
-
-            getContainer().getLogger().error( msg.toString() );
-
-            fail( "Error when invoking Maven, see invoker log above" );
-        }
+        File invokerLogFile = new File( getBasedir(), "target/invoker-FixJavadocMojoTest.txt" );
+        JavadocUtil.invokeMaven( log, testPom, goals, null, invokerLogFile );
     }
 
     // ----------------------------------------------------------------------
@@ -619,82 +556,6 @@
     // ----------------------------------------------------------------------
 
     /**
-     * Try to find the M2_HOME from System.getProperty( "maven.home" ) or M2_HOME env variable.
-     *
-     * @return the M2Home file
-     */
-    private static File getM2Home()
-    {
-        String mavenHome = System.getProperty( "maven.home" );
-
-        if ( mavenHome == null )
-        {
-            try
-            {
-                mavenHome = CommandLineUtils.getSystemEnvVars().getProperty( "M2_HOME" );
-            }
-            catch ( IOException e )
-            {
-                // nop
-            }
-        }
-
-        if ( mavenHome == null )
-        {
-            fail( "Cannot find Maven application directory. Either specify \'maven.home\' system property, or "
-                + "M2_HOME environment variable." );
-        }
-
-        File m2Home = new File( mavenHome );
-        if ( !m2Home.exists() )
-        {
-            fail( "Cannot find Maven application directory. Either specify \'maven.home\' system property, or "
-                + "M2_HOME environment variable." );
-        }
-
-        return m2Home;
-    }
-
-    /**
-     * Try to find the JAVA_HOME from System.getProperty( "java.home" )
-     * By default, System.getProperty( "java.home" ) = JRE_HOME and JRE_HOME should be in the JDK_HOME
-     *
-     * @return the JavaHome file
-     */
-    private static File getJavaHome()
-    {
-        File javaHome;
-        if ( SystemUtils.IS_OS_MAC_OSX )
-        {
-            javaHome = SystemUtils.getJavaHome();
-        }
-        else
-        {
-            javaHome = new File( SystemUtils.getJavaHome(), ".." );
-        }
-
-        if ( javaHome == null || !javaHome.exists() )
-        {
-            try
-            {
-                javaHome = new File( CommandLineUtils.getSystemEnvVars().getProperty( "JAVA_HOME" ) );
-            }
-            catch ( IOException e )
-            {
-                // nop
-            }
-        }
-
-        if ( javaHome == null || !javaHome.exists() )
-        {
-            fail( "Cannot find Java application directory. Either specify \'java.home\' system property, or "
-                + "JAVA_HOME environment variable." );
-        }
-
-        return javaHome;
-    }
-
-    /**
      * Asserts that files are equal. If they are not an AssertionFailedError is thrown.
      *
      * @throws IOException if any