Author: vsiveton Date: Sun Jun 3 04:30:59 2007 New Revision: 543882 URL: http://svn.apache.org/viewvc?view=rev&rev=543882 Log: JXR-53: Add a link to test javadoc
o small refactoring to handle this Modified: maven/jxr/trunk/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AbstractJxrReport.java maven/jxr/trunk/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrReport.java maven/jxr/trunk/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrTestReport.java Modified: maven/jxr/trunk/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AbstractJxrReport.java URL: http://svn.apache.org/viewvc/maven/jxr/trunk/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AbstractJxrReport.java?view=diff&rev=543882&r1=543881&r2=543882 ============================================================================== --- maven/jxr/trunk/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AbstractJxrReport.java (original) +++ maven/jxr/trunk/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AbstractJxrReport.java Sun Jun 3 04:30:59 2007 @@ -46,6 +46,7 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Fabrice Bellingard</a> * @author <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a> + * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Siveton</a> */ public abstract class AbstractJxrReport extends AbstractMavenReport @@ -154,6 +155,14 @@ protected boolean aggregate; /** + * Link the Javadoc from the Source XRef. Defaults to true and will link + * automatically if javadoc plugin is being used. + * + * @parameter expression="${linkJavadoc}" default-value="true" + */ + private boolean linkJavadoc; + + /** * Compiles the list of directories which contain source files that will be included in the JXR report generation. * * @param sourceDirs the List of the source directories @@ -465,6 +474,46 @@ } /** + * @return a String that contains the loaction of the javadocs + */ + private String getJavadocLocation() + { + String location = null; + + if ( linkJavadoc ) + { + // We don't need to do the whole translation thing like normal, because JXR does it internally. + // It probably shouldn't. + if ( getJavadocDir().exists() ) + { + // XRef was already generated by manual execution of a lifecycle binding + location = getJavadocDir().getAbsolutePath(); + } + else + { + // Not yet generated - check if the report is on its way + for ( Iterator reports = getProject().getReportPlugins().iterator(); reports.hasNext(); ) + { + ReportPlugin report = (ReportPlugin) reports.next(); + + String artifactId = report.getArtifactId(); + if ( "maven-javadoc-plugin".equals( artifactId ) ) + { + location = getJavadocDir().getAbsolutePath(); + } + } + } + + if ( location == null ) + { + getLog().warn( "Unable to locate Javadoc to link to - DISABLED" ); + } + } + + return location; + } + + /** * Abstract method that returns the target directory where the generated JXR reports will be put. * * @return a String that contains the target directory name @@ -488,9 +537,9 @@ protected abstract List getSourceRoots( MavenProject project ); /** - * Abstract method that returns the location of the javadoc files. + * Abstract method that returns the directory of the javadoc files. * - * @return a String that contains the loaction of the javadocs + * @return a File for the directory of the javadocs */ - protected abstract String getJavadocLocation(); + protected abstract File getJavadocDir(); } Modified: maven/jxr/trunk/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrReport.java URL: http://svn.apache.org/viewvc/maven/jxr/trunk/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrReport.java?view=diff&rev=543882&r1=543881&r2=543882 ============================================================================== --- maven/jxr/trunk/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrReport.java (original) +++ maven/jxr/trunk/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrReport.java Sun Jun 3 04:30:59 2007 @@ -19,13 +19,11 @@ * under the License. */ -import org.apache.maven.model.ReportPlugin; import org.apache.maven.project.MavenProject; import java.io.File; import java.util.ArrayList; import java.util.Arrays; -import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -71,14 +69,6 @@ private File javadocDir; /** - * Link the Javadoc from the Source XRef. Defaults to true and will link - * automatically if javadoc plugin is being used. - * - * @parameter expression="${linkJavadoc}" default-value="true" - */ - private boolean linkJavadoc; - - /** * @see org.apache.maven.plugin.jxr.AbstractJxrReport#getDestinationDirectory() */ protected String getDestinationDirectory() @@ -172,41 +162,11 @@ } /** - * @see org.apache.maven.plugin.jxr.AbstractJxrReport#getJavadocLocation() + * @see org.apache.maven.plugin.jxr.AbstractJxrReport#getJavadocDir() */ - protected String getJavadocLocation() + protected File getJavadocDir() { - String location = null; - if ( linkJavadoc ) - { - // We don't need to do the whole translation thing like normal, because JXR does it internally. - // It probably shouldn't. - if ( javadocDir.exists() ) - { - // XRef was already generated by manual execution of a lifecycle binding - location = javadocDir.getAbsolutePath(); - } - else - { - // Not yet generated - check if the report is on its way - for ( Iterator reports = getProject().getReportPlugins().iterator(); reports.hasNext(); ) - { - ReportPlugin report = (ReportPlugin) reports.next(); - - String artifactId = report.getArtifactId(); - if ( "maven-javadoc-plugin".equals( artifactId ) ) - { - location = javadocDir.getAbsolutePath(); - } - } - } - - if ( location == null ) - { - getLog().warn( "Unable to locate Javadoc to link to - DISABLED" ); - } - } - return location; + return javadocDir; } /** Modified: maven/jxr/trunk/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrTestReport.java URL: http://svn.apache.org/viewvc/maven/jxr/trunk/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrTestReport.java?view=diff&rev=543882&r1=543881&r2=543882 ============================================================================== --- maven/jxr/trunk/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrTestReport.java (original) +++ maven/jxr/trunk/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrTestReport.java Sun Jun 3 04:30:59 2007 @@ -54,6 +54,13 @@ private String destDir; /** + * Folder where Test Javadoc is generated for this project. + * + * @parameter expression="${project.reporting.outputDirectory}/testapidocs" + */ + private File testJavadocDir; + + /** * @see org.apache.maven.plugin.jxr.AbstractJxrReport#getSourceRoots() */ protected List getSourceRoots() @@ -85,7 +92,7 @@ if ( !"pom".equals( project.getPackaging().toLowerCase() ) ) { - l.addAll( project.getExecutionProject().getCompileSourceRoots() ); + l.addAll( project.getExecutionProject().getTestCompileSourceRoots() ); } if ( project.getExecutionProject() != null ) @@ -138,12 +145,11 @@ } /** - * @see org.apache.maven.plugin.jxr.AbstractJxrReport#getJavadocLocation() + * @see org.apache.maven.plugin.jxr.AbstractJxrReport#getJavadocDir() */ - protected String getJavadocLocation() + protected File getJavadocDir() { - // Don't link Javadoc - return null; + return testJavadocDir; } /**