Author: brianf Date: Fri Oct 6 15:19:27 2006 New Revision: 453791 URL: http://svn.apache.org/viewvc?view=rev&rev=453791 Log: MJAVADOC-93: Allow commas in text arguments doctitle, windowtitle, header, footer, and bottom
Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-default/javadocjar-default-plugin-config.xml 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?view=diff&rev=453791&r1=453790&r2=453791 ============================================================================== --- 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 Fri Oct 6 15:19:27 2006 @@ -1039,16 +1039,16 @@ if ( StringUtils.isEmpty( doclet ) ) { addArgIf( arguments, author, "-author" ); - addArgIfNotEmpty( arguments, "-bottom", quotedArgument( getBottomText( project.getInceptionYear() ) ) ); + addArgIfNotEmpty( arguments, "-bottom", quotedArgument( getBottomText( project.getInceptionYear() ) ), false, false ); addArgIf( arguments, breakiterator, "-breakiterator", SINCE_JAVADOC_1_4 ); addArgIfNotEmpty( arguments, "-charset", quotedArgument( charset ) ); addArgIfNotEmpty( arguments, "-d", quotedPathArgument( javadocOutputDirectory.toString() ) ); addArgIf( arguments, docfilessubdirs, "-docfilessubdirs", SINCE_JAVADOC_1_4 ); addArgIfNotEmpty( arguments, "-docencoding", quotedArgument( docencoding ) ); - addArgIfNotEmpty( arguments, "-doctitle", quotedArgument( doctitle ) ); + addArgIfNotEmpty( arguments, "-doctitle", quotedArgument( doctitle ), false, false ); addArgIfNotEmpty( arguments, "-excludedocfilessubdir", quotedPathArgument( excludedocfilessubdir ), SINCE_JAVADOC_1_4 ); - addArgIfNotEmpty( arguments, "-footer", quotedArgument( footer ) ); + addArgIfNotEmpty( arguments, "-footer", quotedArgument( footer ), false, false ); if ( groups != null ) { for ( int i = 0; i < groups.length; i++ ) @@ -1066,7 +1066,7 @@ } } } - addArgIfNotEmpty( arguments, "-header", quotedArgument( header ) ); + addArgIfNotEmpty( arguments, "-header", quotedArgument( header ), false, false ); addArgIfNotEmpty( arguments, "-helpfile", quotedPathArgument( helpfile ) ); addArgIf( arguments, keywords, "-keywords", SINCE_JAVADOC_1_4_2 ); @@ -1140,7 +1140,7 @@ addArgIf( arguments, use, "-use" ); addArgIf( arguments, version, "-version" ); - addArgIfNotEmpty( arguments, "-windowtitle", quotedArgument( windowtitle ) ); + addArgIfNotEmpty( arguments, "-windowtitle", quotedArgument( windowtitle ), false, false ); } // ---------------------------------------------------------------------- @@ -1933,11 +1933,13 @@ * Moreover, the value could be comma separated. * * @param arguments - * @param key the argument name. - * @param value the argument value to be added. - * @param repeatKey repeat or not the key in the command line + * @param key the argument name. + * @param value the argument value to be added. + * @param repeatKey repeat or not the key in the command line + * @param splitValue if <code>true</code> given value will be tokenized by comma */ - private void addArgIfNotEmpty( List arguments, String key, String value, boolean repeatKey ) + private void addArgIfNotEmpty( List arguments, String key, String value, + boolean repeatKey, boolean splitValue ) { if ( StringUtils.isNotEmpty( value ) ) { @@ -1946,23 +1948,43 @@ arguments.add( key ); } - StringTokenizer token = new StringTokenizer( value, "," ); - while ( token.hasMoreTokens() ) - { - String current = token.nextToken().trim(); - - if ( StringUtils.isNotEmpty( current ) ) - { - arguments.add( current ); - - if ( token.hasMoreTokens() && repeatKey ) - { - arguments.add( key ); + if (splitValue) { + StringTokenizer token = new StringTokenizer( value, "," ); + while ( token.hasMoreTokens() ) + { + String current = token.nextToken().trim(); + + if ( StringUtils.isNotEmpty( current ) ) + { + arguments.add( current ); + + if ( token.hasMoreTokens() && repeatKey ) + { + arguments.add( key ); + } } } + } else { + arguments.add( value ); } } } + + /** + * Convenience method to add an argument to the <code>command line</code> + * if the the value is not null or empty. + * <p/> + * Moreover, the value could be comma separated. + * + * @param arguments + * @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( List arguments, String key, String value, boolean repeatKey ) { + addArgIfNotEmpty(arguments, key, value, repeatKey, true); + } + /** * Convenience method to add an argument to the <code>command line</code> Modified: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-default/javadocjar-default-plugin-config.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-default/javadocjar-default-plugin-config.xml?view=diff&rev=453791&r1=453790&r2=453791 ============================================================================== --- maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-default/javadocjar-default-plugin-config.xml (original) +++ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-default/javadocjar-default-plugin-config.xml Fri Oct 6 15:19:27 2006 @@ -39,11 +39,16 @@ <serialwarn>false</serialwarn> <splitindex>false</splitindex> <stylesheet>java</stylesheet> + <!--commas in following elements are to test MJAVADOC-93--> + <doctitle>doc,title</doctitle> + <bottom>bottom,comma test</bottom> + <footer>my footer, and something</footer> + <header>my header, and something else</header> + <windowtitle>Maven Javadoc Plugin, Javadoc Jar Default Config Test 1.0-SNAPSHOT API</windowtitle> <groups/> <tags/> <use>true</use> <version>true</version> - <windowtitle>Maven Javadoc Plugin Javadoc Jar Default Config Test 1.0-SNAPSHOT API</windowtitle> <links> <param>http://java.sun.com/j2se/1.4.2/docs/api</param> </links>