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 2007/07/12 00:51:47 UTC

svn commit: r555426 - in /maven/plugins/trunk/maven-javadoc-plugin/src: main/java/org/apache/maven/plugin/javadoc/ test/java/org/apache/maven/plugin/javadoc/ test/java/org/apache/maven/plugin/javadoc/stubs/ test/resources/unit/header-footer-test/ test/...

Author: vsiveton
Date: Wed Jul 11 15:51:46 2007
New Revision: 555426

URL: http://svn.apache.org/viewvc?view=rev&rev=555426
Log:
MJAVADOC-133: Javadoc fails if footer contains newlines

o replaced \n by nothing in header and footer parameter
o added a test case

Added:
    maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/HeaderFooterTestMavenProjectStub.java   (with props)
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/header-footer-test-plugin-config.xml   (with props)
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/src/
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/src/main/
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/src/main/java/
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/src/main/java/resources/
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/src/main/java/resources/test/
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/src/main/java/resources/test/App.java   (with props)
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/src/main/java/resources/test2/
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/src/main/java/resources/test2/App2.java   (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=555426&r1=555425&r2=555426
==============================================================================
--- 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 Wed Jul 11 15:51:46 2007
@@ -1249,7 +1249,7 @@
             addArgIfNotEmpty( arguments, "-doctitle", quotedArgument( getDoctitle() ), false, false );
             addArgIfNotEmpty( arguments, "-excludedocfilessubdir", quotedPathArgument( excludedocfilessubdir ),
                               SINCE_JAVADOC_1_4 );
-            addArgIfNotEmpty( arguments, "-footer", quotedArgument( footer ), false, false );
+            addArgIfNotEmpty( arguments, "-footer", quotedArgument( StringUtils.replace( footer, "\n", "" ) ), false, false );
             if ( groups != null )
             {
                 for ( int i = 0; i < groups.length; i++ )
@@ -1267,7 +1267,7 @@
                     }
                 }
             }
-            addArgIfNotEmpty( arguments, "-header", quotedArgument( header ), false, false );
+            addArgIfNotEmpty( arguments, "-header", quotedArgument( StringUtils.replace( header, "\n", "" ) ), false, false );
             addArgIfNotEmpty( arguments, "-helpfile", quotedPathArgument( helpfile ) );
             addArgIf( arguments, keywords, "-keywords", SINCE_JAVADOC_1_4_2 );
 

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=555426&r1=555425&r2=555426
==============================================================================
--- 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 Wed Jul 11 15:51:46 2007
@@ -20,6 +20,7 @@
  */
 
 import org.apache.commons.lang.SystemUtils;
+import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
 import org.codehaus.plexus.util.FileUtils;
 
@@ -755,5 +756,27 @@
         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 );
+    }
+
+    /**
+     * Test newline in the header/footer parameter
+     *
+     * @throws Exception
+     */
+    public void testHeaderFooter()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), "src/test/resources/unit/header-footer-test/header-footer-test-plugin-config.xml" );
+        JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
+        try
+        {
+            mojo.execute();
+        }
+        catch ( MojoExecutionException e )
+        {
+            assertTrue( "Doesnt handle correctly newline for header or footer parameter", false );
+        }
+
+        assertTrue( true );
     }
 }

Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/HeaderFooterTestMavenProjectStub.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/HeaderFooterTestMavenProjectStub.java?view=auto&rev=555426
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/HeaderFooterTestMavenProjectStub.java (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/HeaderFooterTestMavenProjectStub.java Wed Jul 11 15:51:46 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:vincent.siveton@gmail.com">Vincent Siveton</a>
+ */
+public class HeaderFooterTestMavenProjectStub extends MavenProjectStub
+{
+    private Build build;
+
+    public HeaderFooterTestMavenProjectStub()
+    {
+        MavenXpp3Reader pomReader = new MavenXpp3Reader();
+        Model model = null;
+
+        try
+        {
+            model =
+                pomReader.read( new FileReader( new File( getBasedir(), "header-footer-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/header-footer-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/header-footer-test" );
+    }
+}

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/HeaderFooterTestMavenProjectStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/HeaderFooterTestMavenProjectStub.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/header-footer-test-plugin-config.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/header-footer-test-plugin-config.xml?view=auto&rev=555426
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/header-footer-test-plugin-config.xml (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/header-footer-test-plugin-config.xml Wed Jul 11 15:51:46 2007
@@ -0,0 +1,64 @@
+<!--
+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>header-footer.test</groupId>
+  <artifactId>header-footer-test</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <inceptionYear>2007</inceptionYear>
+  <name>Maven Javadoc Plugin header-footer 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.HeaderFooterTestMavenProjectStub"/>
+          <localRepository>${localRepository}</localRepository>
+          <outputDirectory>${basedir}/target/test/unit/header-footer-test/target/site/apidocs</outputDirectory>
+          <windowtitle>Maven Javadoc Plugin header-footer 1.0-SNAPSHOT API</windowtitle>
+          <header>
+            <![CDATA[
+<table border="0" cellpadding="0">
+<tr>
+  <td><img src="{@docRoot}/icon.gif" width="32" /></td>
+  <td>Copyright &#169; All rights reserved.</td>
+</tr>
+</table>
+              ]]>
+          </header>
+          <footer>
+            <![CDATA[
+<table border="0" cellpadding="0">
+<tr>
+  <td><img src="{@docRoot}/icon.gif" width="32" /></td>
+  <td>Copyright &#169; All rights reserved.</td>
+</tr>
+</table>
+              ]]>
+          </footer>
+          <quiet>true</quiet>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/header-footer-test-plugin-config.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/header-footer-test-plugin-config.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/src/main/java/resources/test/App.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/src/main/java/resources/test/App.java?view=auto&rev=555426
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/src/main/java/resources/test/App.java (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/src/main/java/resources/test/App.java Wed Jul 11 15:51:46 2007
@@ -0,0 +1,48 @@
+package resources.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.
+ */
+
+/**
+ * Sample class inside the package to be included in the javadoc
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">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/header-footer-test/src/main/java/resources/test/App.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/src/main/java/resources/test/App.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/src/main/java/resources/test2/App2.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/src/main/java/resources/test2/App2.java?view=auto&rev=555426
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/src/main/java/resources/test2/App2.java (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/src/main/java/resources/test2/App2.java Wed Jul 11 15:51:46 2007
@@ -0,0 +1,48 @@
+package resources.test2;
+
+/*
+ * 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.
+ */
+
+/**
+ * Sample class inside the package to be included in the javadoc
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ */
+public class App2
+{
+    /**
+     * 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/header-footer-test/src/main/java/resources/test2/App2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/header-footer-test/src/main/java/resources/test2/App2.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"