Author: vsiveton Date: Sat Jul 7 03:44:48 2007 New Revision: 554175 URL: http://svn.apache.org/viewvc?view=rev&rev=554175 Log: MJAVADOC-130: Inproper Handling of Tag Definitions
o handled tag option as well o added a test case Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/TagTestMavenProjectStub.java (with props) maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/tag-test/ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/tag-test/src/ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/tag-test/src/main/ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/tag-test/src/main/java/ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/tag-test/src/main/java/tag/ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/tag-test/src/main/java/tag/test/ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/tag-test/src/main/java/tag/test/App.java (with props) maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/tag-test/tag-test-plugin-config.xml (with props) 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/java/org/apache/maven/plugin/javadoc/JavadocReportTest.java Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java?view=diff&rev=554175&r1=554174&r2=554175 ============================================================================== --- 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 7 03:44:48 2007 @@ -1324,17 +1324,20 @@ { for ( int i = 0; i < tags.length; i++ ) { - if ( ( tags[i] == null ) || ( StringUtils.isEmpty( tags[i].getName() ) ) - || ( StringUtils.isEmpty( tags[i].getPlacement() ) ) ) + if ( StringUtils.isEmpty( tags[i].getName() ) ) { - getLog().info( "A tag option is empty. Ignore this option." ); + getLog().info( "A tag name is empty. Ignore this option." ); } else { - String value = "\"" + tags[i].getName() + ":" + tags[i].getPlacement(); - if ( StringUtils.isNotEmpty( tags[i].getHead() ) ) + String value = "\"" + tags[i].getName(); + if ( StringUtils.isNotEmpty( tags[i].getPlacement() ) ) { - value += ":" + quotedArgument( tags[i].getHead() ); + value += ":" + tags[i].getPlacement(); + if ( StringUtils.isNotEmpty( tags[i].getHead() ) ) + { + value += ":" + tags[i].getHead(); + } } value += "\""; addArgIfNotEmpty( arguments, "-tag", value, SINCE_JAVADOC_1_4 ); Modified: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocReportTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocReportTest.java?view=diff&rev=554175&r1=554174&r2=554175 ============================================================================== --- maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocReportTest.java (original) +++ maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocReportTest.java Sat Jul 7 03:44:48 2007 @@ -35,6 +35,8 @@ public class JavadocReportTest extends AbstractMojoTestCase { + private static final String LINE_SEPARATOR = " "; + /** * @see junit.framework.TestCase#setUp() */ @@ -145,6 +147,7 @@ * Convenience method that reads the contents of the specified file object into a string with a * <code>space</code> as line separator. * + * @see #LINE_SEPARATOR * @param file the file to be read * @return a String object that contains the contents of the file * @throws IOException if any @@ -157,7 +160,7 @@ while ( ( strTmp = in.readLine() ) != null ) { - str = str + " " + strTmp; + str = str + LINE_SEPARATOR + strTmp; } in.close(); @@ -689,23 +692,22 @@ mojo.execute(); // Test overview - String lineSeparator = " "; File overviewSummary = new File( getBasedir(), "target/test/unit/aggregate-resources-test/target/site/apidocs/overview-summary.html" ); assertTrue( FileUtils.fileExists( overviewSummary.getAbsolutePath() ) ); String readed = readFile( overviewSummary ); - assertTrue( readed.indexOf( "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + lineSeparator + assertTrue( readed.indexOf( "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + LINE_SEPARATOR + "<TD WIDTH=\"20%\"><B><A HREF=\"resources/test/package-summary.html\">resources.test</A></B></TD>" - + lineSeparator + "<TD>blabla</TD>" + lineSeparator + "</TR>" ) != -1 ); - assertTrue( readed.indexOf( "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + lineSeparator + + LINE_SEPARATOR + "<TD>blabla</TD>" + LINE_SEPARATOR + "</TR>" ) != -1 ); + assertTrue( readed.indexOf( "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + LINE_SEPARATOR + "<TD WIDTH=\"20%\"><B><A HREF=\"resources/test2/package-summary.html\">resources.test2</A></B></TD>" - + lineSeparator + "<TD> </TD>" + lineSeparator + "</TR>" ) != -1 ); - assertTrue( readed.indexOf( "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + lineSeparator + + LINE_SEPARATOR + "<TD> </TD>" + LINE_SEPARATOR + "</TR>" ) != -1 ); + assertTrue( readed.indexOf( "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + LINE_SEPARATOR + "<TD WIDTH=\"20%\"><B><A HREF=\"resources2/test/package-summary.html\">resources2.test</A></B></TD>" - + lineSeparator + "<TD>blabla</TD>" + lineSeparator + "</TR>" ) != -1 ); - assertTrue( readed.indexOf( "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + lineSeparator + + LINE_SEPARATOR + "<TD>blabla</TD>" + LINE_SEPARATOR + "</TR>" ) != -1 ); + assertTrue( readed.indexOf( "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + LINE_SEPARATOR + "<TD WIDTH=\"20%\"><B><A HREF=\"resources2/test2/package-summary.html\">resources2.test2</A></B></TD>" - + lineSeparator + "<TD> </TD>" + lineSeparator + "</TR>" ) != -1 ); + + LINE_SEPARATOR + "<TD> </TD>" + LINE_SEPARATOR + "</TR>" ) != -1 ); // Test doc-files File app = new File( getBasedir(), @@ -726,11 +728,32 @@ public void testPom() throws Exception { - File testPom = new File( getBasedir(), - "src/test/resources/unit/pom-test/pom-test-plugin-config.xml" ); + File testPom = new File( getBasedir(), "src/test/resources/unit/pom-test/pom-test-plugin-config.xml" ); JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom ); mojo.execute(); assertFalse( new File( getBasedir(), "target/test/unit/pom-test" ).exists() ); + } + + /** + * Test the javadoc with tag. + * + * @throws Exception + */ + public void testTag() + throws Exception + { + File testPom = new File( getBasedir(), "src/test/resources/unit/tag-test/tag-test-plugin-config.xml" ); + JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom ); + mojo.execute(); + + File app = new File( getBasedir(), "target/test/unit/tag-test/target/site/apidocs/tag/test/App.html" ); + assertTrue( FileUtils.fileExists( app.getAbsolutePath() ) ); + String readed = readFile( app ); + assertTrue( readed.indexOf( "<B>To do something:</B>" ) != -1 ); + assertTrue( readed.indexOf( "<B>Generator Class:</B>" ) != -1 ); + assertTrue( readed.indexOf( "<B>Version:</B>" ) != -1 ); + assertTrue( readed.indexOf( "<DT><B>Version:</B></DT>" + LINE_SEPARATOR + " <DD>1.0</DD>" + LINE_SEPARATOR + + "</DL>" ) != -1 ); } } Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/TagTestMavenProjectStub.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/TagTestMavenProjectStub.java?view=auto&rev=554175 ============================================================================== --- maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/TagTestMavenProjectStub.java (added) +++ maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/TagTestMavenProjectStub.java Sat Jul 7 03:44:48 2007 @@ -0,0 +1,96 @@ +package org.apache.maven.plugin.javadoc.stubs; + +/* + * 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 org.apache.maven.model.Build; +import org.apache.maven.model.Model; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.apache.maven.plugin.testing.stubs.MavenProjectStub; + +import java.io.File; +import java.io.FileReader; +import java.util.ArrayList; +import java.util.List; + +/** + * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Siveton</a> + */ +public class TagTestMavenProjectStub extends MavenProjectStub +{ + private Build build; + + public TagTestMavenProjectStub() + { + MavenXpp3Reader pomReader = new MavenXpp3Reader(); + Model model = null; + + try + { + model = + pomReader.read( new FileReader( new File( getBasedir(), "tag-test-plugin-config.xml" ) ) ); + setModel( model ); + } + catch ( Exception e ) + { + throw new RuntimeException( e ); + } + + setGroupId( model.getGroupId() ); + setArtifactId( model.getArtifactId() ); + setVersion( model.getVersion() ); + setName( model.getName() ); + setUrl( model.getUrl() ); + setPackaging( model.getPackaging() ); + + Build build = new Build(); + build.setFinalName( model.getArtifactId() ); + build.setSourceDirectory( getBasedir() + "/src/main/java" ); + build.setDirectory( super.getBasedir() + "/target/test/unit/tag-test/target" ); + setBuild( build ); + + List compileSourceRoots = new ArrayList(); + compileSourceRoots.add( getBasedir() + "/src/main/java" ); + setCompileSourceRoots( compileSourceRoots ); + } + + /** + * @see org.apache.maven.plugin.testing.stubs.MavenProjectStub#getBuild() + */ + public Build getBuild() + { + return build; + } + + /** + * @see org.apache.maven.plugin.testing.stubs.MavenProjectStub#setBuild(org.apache.maven.model.Build) + */ + public void setBuild( Build build ) + { + this.build = build; + } + + /** + * @see org.apache.maven.plugin.testing.stubs.MavenProjectStub#getBasedir() + */ + public File getBasedir() + { + return new File( super.getBasedir() + "/src/test/resources/unit/tag-test" ); + } +} Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/TagTestMavenProjectStub.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/TagTestMavenProjectStub.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/tag-test/src/main/java/tag/test/App.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/tag-test/src/main/java/tag/test/App.java?view=auto&rev=554175 ============================================================================== --- maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/tag-test/src/main/java/tag/test/App.java (added) +++ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/tag-test/src/main/java/tag/test/App.java Sat Jul 7 03:44:48 2007 @@ -0,0 +1,52 @@ +package tag.test; + +/* + * 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. + */ + +/** + * App class + * + * @generatorClass toto + * @todo review it + * @version 1.0 + * + * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Siveton</a> + */ +public class App +{ + /** + * The main method + * + * @param args an array of strings that contains the arguments + */ + public static void main( String[] args ) + { + System.out.println( "Sample Application." ); + } + + /** + * Sample method that prints out the parameter string. + * + * @param str The string value to be printed. + */ + protected void sampleMethod( String str ) + { + System.out.println( str ); + } +} Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/tag-test/src/main/java/tag/test/App.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/tag-test/src/main/java/tag/test/App.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/tag-test/tag-test-plugin-config.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/tag-test/tag-test-plugin-config.xml?view=auto&rev=554175 ============================================================================== --- maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/tag-test/tag-test-plugin-config.xml (added) +++ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/tag-test/tag-test-plugin-config.xml Sat Jul 7 03:44:48 2007 @@ -0,0 +1,59 @@ +<!-- +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> + <modelVersion>4.0.0</modelVersion> + <groupId>resources.test</groupId> + <artifactId>resources-test</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <inceptionYear>2007</inceptionYear> + <name>Maven Javadoc Plugin tag Test</name> + <url>http://maven.apache.org</url> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <configuration> + <project implementation="org.apache.maven.plugin.javadoc.stubs.TagTestMavenProjectStub"/> + <localRepository>${localRepository}</localRepository> + <outputDirectory>${basedir}/target/test/unit/tag-test/target/site/apidocs</outputDirectory> + <windowtitle>Maven Javadoc Plugin tag 1.0-SNAPSHOT API</windowtitle> + <quiet>true</quiet> + <tags> + <tag> + <name>todo</name> + <placement>a</placement> + <head>To do something:</head> + </tag> + <tag> + <name>generatorClass</name> + <head>Generator Class:</head> + <placement>t</placement> + </tag> + <tag> + <name>version</name> + </tag> + </tags> + </configuration> + </plugin> + </plugins> + </build> +</project> Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/tag-test/tag-test-plugin-config.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/tag-test/tag-test-plugin-config.xml ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision"