From f862da60b6b5487af1006688e631123ebde20e0e Mon Sep 17 00:00:00 2001 From: Vincent Siveton Date: Sat, 6 Aug 2005 14:32:43 +0000 Subject: [PATCH] Added methods to repeat arguments (for group, tag, link and linkoffline options provided by the Javadoc standard doclet). Added plexus-utils as transitive dep. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@230549 13f79535-47bb-0310-9956-ffa450edef68 --- maven-plugins/maven-javadoc-plugin/pom.xml | 4 + .../maven/plugin/javadoc/JavadocReport.java | 178 ++++++++++++------ .../projects/javadoc-plugin-test1/pom.xml | 4 + .../maven/plugin/javadoc/test1/App.java | 10 + 4 files changed, 135 insertions(+), 61 deletions(-) diff --git a/maven-plugins/maven-javadoc-plugin/pom.xml b/maven-plugins/maven-javadoc-plugin/pom.xml index 25a30ca7f3..d7d5de4f03 100644 --- a/maven-plugins/maven-javadoc-plugin/pom.xml +++ b/maven-plugins/maven-javadoc-plugin/pom.xml @@ -40,6 +40,10 @@ commons-lang 2.1 + + plexus + plexus-utils + diff --git a/maven-plugins/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocReport.java b/maven-plugins/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocReport.java index f6dd817acc..3133153c71 100644 --- a/maven-plugins/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocReport.java +++ b/maven-plugins/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocReport.java @@ -26,7 +26,6 @@ import java.util.Locale; import java.util.StringTokenizer; import org.apache.commons.lang.ClassUtils; -import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.SystemUtils; import org.apache.commons.lang.math.NumberUtils; import org.apache.maven.project.MavenProject; @@ -37,6 +36,7 @@ import org.codehaus.doxia.sink.Sink; import org.codehaus.doxia.site.renderer.SiteRenderer; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; +import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; import org.codehaus.plexus.util.cli.DefaultConsumer; @@ -60,24 +60,29 @@ public class JavadocReport extends AbstractMavenReport { /** The current class directory */ - private static final String RESOURCE_DIR = ClassUtils.getPackageName(JavadocReport.class).replace('.', '/'); + private static final String RESOURCE_DIR = ClassUtils.getPackageName( JavadocReport.class ).replace( '.', '/' ); /** Default location for css */ private static final String DEFAULT_CSS_NAME = "stylesheet.css"; + private static final String RESOURCE_CSS_DIR = RESOURCE_DIR + "/css"; - + // Using for the plugin:xdoc goal. Best way? /** Default bottom */ private static final String DEFAULT_BOTTOM = "Copyright ${project.inceptionYear-currentYear} ${project.organization.name}. All Rights Reserved."; + /** Default bottom */ private static final String DEFAULT_DESTDIR = "${project.build.directory}/site/apidocs"; + /** Default doctitle */ private static final String DEFAULT_DOCTITLE = "${windowtitle}"; + /** Default organization name */ private static final String DEFAULT_ORGANIZATION_NAME = "The Apache Software Foundation"; + /** Default window title */ private static final String DEFAULT_WINDOW_TITLE = "${project.name} ${project.version} API"; - + /** * @parameter expression="${project.build.directory}/site" * @required @@ -112,7 +117,7 @@ public class JavadocReport * See breakiterator. * * @parameter expression="${breakiterator}" - * default-value="false" + * default-value="false" */ private boolean breakiterator = false; @@ -185,7 +190,7 @@ public class JavadocReport * See 1.1. * * @parameter expression="${old}" - * default-value="false" + * default-value="false" */ private boolean old = false; @@ -202,7 +207,7 @@ public class JavadocReport * See package. * * @parameter expression="${package}" - * default-value="true" + * default-value="true" */ private boolean package_ = true; @@ -211,7 +216,7 @@ public class JavadocReport * See private * * @parameter expression="${private}" - * default-value="false" + * default-value="false" */ private boolean private_ = false; @@ -220,7 +225,7 @@ public class JavadocReport * See protected. * * @parameter expression="${protected}" - * default-value="false" + * default-value="false" */ private boolean protected_ = false; @@ -229,7 +234,7 @@ public class JavadocReport * See public. * * @parameter expression="${public}" - * default-value="false" + * default-value="false" */ private boolean public_ = false; @@ -238,7 +243,7 @@ public class JavadocReport * See quiet. * * @parameter expression="${quiet}" - * default-value="false" + * default-value="false" */ private boolean quiet = false; @@ -255,7 +260,7 @@ public class JavadocReport * See verbose. * * @parameter expression="${verbose}" - * default-value="false" + * default-value="false" */ private boolean verbose = false; @@ -266,7 +271,7 @@ public class JavadocReport * See author. * * @parameter expression="${author}" - * default-value="true" + * default-value="true" */ private boolean author = true; @@ -275,7 +280,7 @@ public class JavadocReport * See bottom. * * @parameter expression="${bottom}" - * default-value="Copyright ${project.inceptionYear-currentYear} ${project.organization.name}. All Rights Reserved." + * default-value="Copyright ${project.inceptionYear-currentYear} ${project.organization.name}. All Rights Reserved." */ private String bottom; @@ -284,7 +289,7 @@ public class JavadocReport * See charset. * * @parameter expression="${charset}" - * default-value="ISO-8859-1" + * default-value="ISO-8859-1" */ private String charset = "ISO-8859-1"; @@ -293,7 +298,7 @@ public class JavadocReport * See d. * * @parameter expression="${destDir}" - * default-value="${project.build.directory}/site/apidocs" + * default-value="${project.build.directory}/site/apidocs" */ private String destDir; @@ -302,7 +307,7 @@ public class JavadocReport * See docfilessubdirs. * * @parameter expression="${docfilessubdirs}" - * default-value="false" + * default-value="false" */ private boolean docfilessubdirs = false; @@ -319,7 +324,7 @@ public class JavadocReport * See doctitle. * * @parameter expression="${doctitle}" - * default-value="${windowtitle}" + * default-value="${windowtitle}" */ private String doctitle; @@ -342,6 +347,7 @@ public class JavadocReport /** * Separates packages on the overview page into whatever groups you specify, one group per table. * See group. + * It is a comma separated String. * * @parameter expression="${group}" */ @@ -366,6 +372,7 @@ public class JavadocReport /** * Creates links to existing javadoc-generated documentation of external referenced classes. * See link. + * It is a comma separated String. * * @parameter expression="${link}" */ @@ -374,6 +381,7 @@ public class JavadocReport /** * This option is a variation of -link; they both create links to javadoc-generated documentation for external referenced classes. * See linkoffline. + * It is a comma separated String. * * @parameter expression="${linkoffline}" */ @@ -384,7 +392,7 @@ public class JavadocReport * See linksource. * * @parameter expression="${linksource}" - * default-value="false" + * default-value="false" */ private boolean linksource = false; @@ -393,25 +401,25 @@ public class JavadocReport * Ssee nocomment. * * @parameter expression="${nocomment}" - * default-value="false" + * default-value="false" */ private boolean nocomment = false; /** * Prevents the generation of any deprecated API at all in the documentation. - * See nodeprecated. + * See nodeprecated. * * @parameter expression="${nodeprecated}" - * default-value="false" + * default-value="false" */ private boolean nodeprecated = false; - + /** * Prevents the generation of the file containing the list of deprecated APIs (deprecated-list.html) and the link in the navigation bar to that page. * See nodeprecatedlist. * * @parameter expression="${nodeprecatedlist}" - * default-value="false" + * default-value="false" */ private boolean nodeprecatedlist = false; @@ -420,7 +428,7 @@ public class JavadocReport * See nohelp. * * @parameter expression="${nohelp}" - * default-value="false" + * default-value="false" */ private boolean nohelp = false; @@ -429,7 +437,7 @@ public class JavadocReport * See noindex. * * @parameter expression="${noindex}" - * default-value="false" + * default-value="false" */ private boolean noindex = false; @@ -438,7 +446,7 @@ public class JavadocReport * See nonavbar. * * @parameter expression="${nonavbar}" - * default-value="false" + * default-value="false" */ private boolean nonavbar = false; @@ -455,7 +463,7 @@ public class JavadocReport * See nosince. * * @parameter expression="${nosince}" - * default-value="false" + * default-value="false" */ private boolean nosince = false; @@ -464,7 +472,7 @@ public class JavadocReport * See notree. * * @parameter expression="${notree}" - * default-value="false" + * default-value="false" */ private boolean notree = false; @@ -473,7 +481,7 @@ public class JavadocReport * See serialwarn * * @parameter expression="${serialwarn}" - * default-value="false" + * default-value="false" */ private boolean serialwarn = false; @@ -483,7 +491,7 @@ public class JavadocReport * See splitindex. * * @parameter expression="${splitindex}" - * default-value="false" + * default-value="false" */ private boolean splitindex = false; @@ -498,6 +506,7 @@ public class JavadocReport /** * Enables the Javadoc tool to interpret a simple, one-argument custom block tag tagname in doc comments. * See tag. + * It is a comma separated String. * * @parameter expression="${tag}" */ @@ -524,7 +533,7 @@ public class JavadocReport * See use. * * @parameter expression="${use}" - * default-value="true" + * default-value="true" */ private boolean use = true; @@ -533,7 +542,7 @@ public class JavadocReport * See version. * * @parameter expression="${version}" - * default-value="true" + * default-value="true" */ private boolean version = true; @@ -543,9 +552,10 @@ public class JavadocReport * See windowtitle. * * @parameter expression="${windowtitle}" - * default-value="${project.name} ${project.version} API" + * default-value="${project.name} ${project.version} API" */ private String windowtitle; + // End JavaDoc parameters /** The command line built to execute Javadoc. */ @@ -690,15 +700,16 @@ public class JavadocReport } else { - if ( ( NumberUtils.isDigits( this.maxmemory.substring( 0, this.maxmemory.length() - 1) ) ) - && ( this.maxmemory.toLowerCase().endsWith( "m" ) ) ) + if ( ( NumberUtils.isDigits( this.maxmemory.substring( 0, this.maxmemory.length() - 1 ) ) ) + && ( this.maxmemory.toLowerCase().endsWith( "m" ) ) ) { - addArgIf( true, "-J-Xmx" + this.maxmemory ); } else { - getLog().error( "The maxmemory '" + this.maxmemory + "' is not a valid number. Ignore this option." ); + getLog().error( + "The maxmemory '" + this.maxmemory + + "' is not a valid number. Ignore this option." ); } } } @@ -711,15 +722,16 @@ public class JavadocReport } else { - if ( ( NumberUtils.isDigits( this.minmemory.substring( 0, this.minmemory.length() - 1) ) ) - && ( this.minmemory.toLowerCase().endsWith( "m" ) ) ) + if ( ( NumberUtils.isDigits( this.minmemory.substring( 0, this.minmemory.length() - 1 ) ) ) + && ( this.minmemory.toLowerCase().endsWith( "m" ) ) ) { - addArgIf( true, "-J-Xms" + this.minmemory ); } else { - getLog().error( "The minmemory '" + this.minmemory + "' is not a valid number. Ignore this option." ); + getLog().error( + "The minmemory '" + this.minmemory + + "' is not a valid number. Ignore this option." ); } } } @@ -752,7 +764,8 @@ public class JavadocReport { this.bottom = "Copyright © " + year + " "; - if ( ( model.getOrganization() != null ) && ( !StringUtils.isEmpty( model.getOrganization().getName() ) ) ) + if ( ( model.getOrganization() != null ) + && ( !StringUtils.isEmpty( model.getOrganization().getName() ) ) ) { this.bottom += model.getOrganization().getName(); } @@ -794,11 +807,11 @@ public class JavadocReport addArgIfNotEmpty( "-excludePackageNames", this.excludePackageNames ); addArgIfNotEmpty( "-excludedocfilessubdir", this.excludedocfilessubdir, 1.4f ); addArgIfNotEmpty( "-footer", this.footer ); - addArgIfNotEmpty( "-group", this.group ); + addArgIfNotEmpty( "-group", this.group, true ); addArgIfNotEmpty( "-header", this.header ); addArgIfNotEmpty( "-helpfile", this.helpfile ); - addArgIfNotEmpty( "-link", this.link ); - addArgIfNotEmpty( "-linkoffline", this.linkoffline ); + addArgIfNotEmpty( "-link", this.link, true ); + addArgIfNotEmpty( "-linkoffline", this.linkoffline, true ); addArgIf( this.linksource, "-linksource", 1.4f ); addArgIf( this.nodeprecated, "-nodeprecated" ); addArgIf( this.nodeprecatedlist, "-nodeprecatedlist" ); @@ -812,7 +825,7 @@ public class JavadocReport addArgIf( this.serialwarn, "-serialwarn" ); addArgIf( this.splitindex, "-splitindex" ); addArgIfNotEmpty( "-stylesheetfile", this.stylesheetfile ); - addArgIfNotEmpty( "-tag", this.tag, 1.4f ); + addArgIfNotEmpty( "-tag", this.tag, 1.4f, true ); addArgIfNotEmpty( "-taglet", this.taglet, 1.4f ); addArgIfNotEmpty( "-tagletpath", this.tagletpath, 1.4f ); addArgIf( this.use, "-use" ); @@ -824,7 +837,8 @@ public class JavadocReport getLog().info( Commandline.toString( cmd.getCommandline() ) ); - final int exitCode = CommandLineUtils.executeCommandLine( cmd, new DefaultConsumer(), new DefaultConsumer() ); + final int exitCode = CommandLineUtils + .executeCommandLine( cmd, new DefaultConsumer(), new DefaultConsumer() ); if ( exitCode != 0 ) { throw new MavenReportException( "Exit code: " + exitCode ); @@ -854,11 +868,13 @@ public class JavadocReport { final String javadocCommand = "javadoc" + ( SystemUtils.IS_OS_WINDOWS ? ".exe" : "" ); // For IBM's JDK 1.2 - final File javadocExe = ( SystemUtils.IS_OS_AIX ? new File( SystemUtils.getJavaHome() + "/../sh", javadocCommand ) - : new File( SystemUtils.getJavaHome() + "/../bin", javadocCommand ) ); + final File javadocExe = ( SystemUtils.IS_OS_AIX ? new File( SystemUtils.getJavaHome() + "/../sh", + javadocCommand ) : new File( SystemUtils + .getJavaHome() + + "/../bin", javadocCommand ) ); getLog().debug( "Javadoc executable=[" + javadocExe.getAbsolutePath() + "]" ); - + return javadocExe.getAbsolutePath(); } @@ -906,10 +922,27 @@ public class JavadocReport *

* Moreover, the value could be comma separated. * + * @see #addArgIfNotEmpty(String, String, boolean) + * * @param key the argument name. * @param value the argument value to be added. */ private void addArgIfNotEmpty( final String key, final String value ) + { + addArgIfNotEmpty( key, value, false ); + } + + /** + * Convenience method to add an argument to the command line + * if the the value is not null or empty. + *

+ * Moreover, the value could be comma separated. + * + * @param key the argument name. + * @param value the argument value to be added. + * @param repeatKey repeat or not the key in the command line + */ + private void addArgIfNotEmpty( final String key, final String value, final boolean repeatKey ) { if ( !StringUtils.isEmpty( value ) ) { @@ -919,11 +952,35 @@ public class JavadocReport while ( token.hasMoreTokens() ) { String current = token.nextToken().trim(); - this.cmd.createArgument().setValue( current ); + + if ( !StringUtils.isEmpty( current ) ) + { + this.cmd.createArgument().setValue( current ); + + if ( token.hasMoreTokens() && repeatKey ) + { + this.cmd.createArgument().setValue( key ); + } + } } } } + /** + * Convenience method to add an argument to the command line + * regarding the requested Java version. + * + * @see #addArgIfNotEmpty(String, String, float, boolean) + * + * @param key the argument name. + * @param value the argument value to be added. + * @param requiredJavaVersion the required Java version, for example 1.31f or 1.4f + */ + private void addArgIfNotEmpty( final String key, final String value, final float requiredJavaVersion ) + { + addArgIfNotEmpty( key, value, requiredJavaVersion, false ); + } + /** * Convenience method to add an argument to the command line * regarding the requested Java version. @@ -931,18 +988,17 @@ public class JavadocReport * @see #addArgIfNotEmpty(String, String) * @see SystemUtils.html#isJavaVersionAtLeast(float) * - * @param key - * the argument name. - * @param value - * the argument value to be added. - * @param requiredJavaVersion - * the required Java version, for example 1.31f or 1.4f + * @param key the argument name. + * @param value the argument value to be added. + * @param requiredJavaVersion the required Java version, for example 1.31f or 1.4f + * @param repeatKey repeat or not the key in the command line */ - private void addArgIfNotEmpty( final String key, final String value, final float requiredJavaVersion ) + private void addArgIfNotEmpty( final String key, final String value, final float requiredJavaVersion, + final boolean repeatKey ) { if ( SystemUtils.isJavaVersionAtLeast( requiredJavaVersion ) ) { - addArgIfNotEmpty( key, value ); + addArgIfNotEmpty( key, value, repeatKey ); } else { @@ -964,7 +1020,7 @@ public class JavadocReport { return JavadocReport.class.getClassLoader().getResourceAsStream( resource ); } - + /** * Convenience method that copy the DEFAULT_STYLESHEET_NAME file from the current class * loader to the output directory. diff --git a/maven-plugins/maven-javadoc-plugin/src/test/projects/javadoc-plugin-test1/pom.xml b/maven-plugins/maven-javadoc-plugin/src/test/projects/javadoc-plugin-test1/pom.xml index 250a176dc3..50f89f7dbe 100644 --- a/maven-plugins/maven-javadoc-plugin/src/test/projects/javadoc-plugin-test1/pom.xml +++ b/maven-plugins/maven-javadoc-plugin/src/test/projects/javadoc-plugin-test1/pom.xml @@ -55,6 +55,10 @@ 128m 512 Copyright me + true + http://java.sun.com/j2se/1.4.2/docs/api, http://maven.apache.org/apidocs/ + "Core Packages" "org.apache.maven.plugin.javadoc.test1", "Extension Packages" "org.apache.maven.plugin.javadoc.test2" + .usage:a:Usage:, .todo:a:To do something:, .fixme:a:Fixme: diff --git a/maven-plugins/maven-javadoc-plugin/src/test/projects/javadoc-plugin-test1/src/main/java/org/apache/maven/plugin/javadoc/test1/App.java b/maven-plugins/maven-javadoc-plugin/src/test/projects/javadoc-plugin-test1/src/main/java/org/apache/maven/plugin/javadoc/test1/App.java index 494a97620c..def1ac9047 100644 --- a/maven-plugins/maven-javadoc-plugin/src/test/projects/javadoc-plugin-test1/src/main/java/org/apache/maven/plugin/javadoc/test1/App.java +++ b/maven-plugins/maven-javadoc-plugin/src/test/projects/javadoc-plugin-test1/src/main/java/org/apache/maven/plugin/javadoc/test1/App.java @@ -6,6 +6,16 @@ package org.apache.maven.plugin.javadoc.test1; */ public class App { + /** + * @.todo to do + * @.usage usage is java org.apache.maven.plugin.javadoc.test1.App + * @.fixme Fix me! + * + * @see System#out + * @see org.apache.maven.MavenException + * + * @param args + */ public static void main( String[] args ) { System.out.println( "Hello World!" );