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 2009/07/17 12:20:09 UTC

svn commit: r795029 - in /maven/plugins/trunk/maven-javadoc-plugin/src: main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java test/java/org/apache/maven/plugin/javadoc/JavadocReportTest.java

Author: vsiveton
Date: Fri Jul 17 10:20:08 2009
New Revision: 795029

URL: http://svn.apache.org/viewvc?rev=795029&view=rev
Log:
MJAVADOC-216: Stylesheet file loaded from classpath
MJAVADOC-239: Helpfile loaded from classpath

o more test

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?rev=795029&r1=795028&r2=795029&view=diff
==============================================================================
--- 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 Jul 17 10:20:08 2009
@@ -4147,7 +4147,7 @@
         if ( resourceURL != null )
         {
             getLog().debug( inputResourceName + " found in the main src directory of the project." );
-            return resourceURL.getFile();
+            return FileUtils.toFile( resourceURL ).getAbsolutePath();
         }
 
         classPath.clear();
@@ -4161,7 +4161,7 @@
         if ( resourceURL != null )
         {
             getLog().debug( inputResourceName + " found in the main resources directories of the project." );
-            return resourceURL.getFile();
+            return FileUtils.toFile( resourceURL ).getAbsolutePath();
         }
 
         if ( javadocDirectory.exists() )
@@ -4172,7 +4172,7 @@
             if ( resourceURL != null )
             {
                 getLog().debug( inputResourceName + " found in the main javadoc directory of the project." );
-                return resourceURL.getFile();
+                return FileUtils.toFile( resourceURL ).getAbsolutePath();
             }
         }
 

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?rev=795029&r1=795028&r2=795029&view=diff
==============================================================================
--- 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 Fri Jul 17 10:20:08 2009
@@ -81,48 +81,42 @@
         // UMLGraph
         // ----------------------------------------------------------------------
 
-        FileUtils.copyDirectoryStructure( new File( getBasedir(),
-                                                    "src/test/resources/unit/doclet-test/artifact-doclet" ),
-                                          localRepo );
+        File sourceDir = new File( getBasedir(), "src/test/resources/unit/doclet-test/artifact-doclet" );
+        assertTrue( sourceDir.exists() );
+        FileUtils.copyDirectoryStructure( sourceDir, localRepo );
 
         // ----------------------------------------------------------------------
         // UMLGraph-bis
         // ----------------------------------------------------------------------
 
-        FileUtils.copyDirectoryStructure( new File( getBasedir(),
-                                                    "src/test/resources/unit/doclet-path-test/artifact-doclet" ),
-                                          localRepo );
+        sourceDir = new File( getBasedir(), "src/test/resources/unit/doclet-path-test/artifact-doclet" );
+        assertTrue( sourceDir.exists() );
+        FileUtils.copyDirectoryStructure( sourceDir, localRepo );
 
         // ----------------------------------------------------------------------
         // commons-attributes-compiler
         // http://www.tullmann.org/pat/taglets/
         // ----------------------------------------------------------------------
 
-        FileUtils
-                 .copyDirectoryStructure(
-                                          new File( getBasedir(),
-                                                    "src/test/resources/unit/taglet-test/artifact-taglet" ),
-                                          localRepo );
+        sourceDir = new File( getBasedir(), "src/test/resources/unit/taglet-test/artifact-taglet" );
+        assertTrue( sourceDir.exists() );
+        FileUtils.copyDirectoryStructure( sourceDir, localRepo );
 
         // ----------------------------------------------------------------------
         // stylesheetfile-test
         // ----------------------------------------------------------------------
 
-        FileUtils
-                 .copyDirectoryStructure(
-                                          new File( getBasedir(),
-                                                    "src/test/resources/unit/stylesheetfile-test/artifact-stylesheetfile" ),
-                                          localRepo );
+        sourceDir = new File( getBasedir(), "src/test/resources/unit/stylesheetfile-test/artifact-stylesheetfile" );
+        assertTrue( sourceDir.exists() );
+        FileUtils.copyDirectoryStructure( sourceDir, localRepo );
 
         // ----------------------------------------------------------------------
         // helpfile-test
         // ----------------------------------------------------------------------
 
-        FileUtils
-                 .copyDirectoryStructure(
-                                          new File( getBasedir(),
-                                                    "src/test/resources/unit/helpfile-test/artifact-helpfile" ),
-                                          localRepo );
+        sourceDir = new File( getBasedir(), "src/test/resources/unit/helpfile-test/artifact-helpfile" );
+        assertTrue( sourceDir.exists() );
+        FileUtils.copyDirectoryStructure( sourceDir, localRepo );
 
         // Remove SCM files
         List files =
@@ -992,6 +986,8 @@
         File stylesheetfile =
             new File( getBasedir(), "target/test/unit/stylesheetfile-test/target/site/apidocs/stylesheet.css" );
 
+        File options = new File( getBasedir(), "target/test/unit/stylesheetfile-test/target/site/apidocs/options" );
+
         // stylesheet == maven OR java
         setVariableValueToObject( mojo, "stylesheet", "javamaven" );
 
@@ -1012,6 +1008,9 @@
         String content = readFile( stylesheetfile );
         assertTrue( content.indexOf( "/* Javadoc style sheet */" ) != -1 );
 
+        String optionsContent = readFile( options );
+        assertTrue( optionsContent.indexOf( "-stylesheetfile" ) == -1 );
+
         // stylesheet == maven
         setVariableValueToObject( mojo, "stylesheet", "maven" );
         mojo.execute();
@@ -1020,6 +1019,11 @@
         assertTrue( content.indexOf( "/* Javadoc style sheet */" ) != -1
             && content.indexOf( "Licensed to the Apache Software Foundation (ASF) under one" ) != -1 );
 
+        optionsContent = readFile( options );
+        assertTrue( optionsContent.indexOf( "-stylesheetfile" ) != -1 );
+        assertTrue( optionsContent
+                                  .indexOf( "'" + stylesheetfile.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) != -1 );
+
         // stylesheetfile defined as a project resource
         setVariableValueToObject( mojo, "stylesheet", null );
         setVariableValueToObject( mojo, "stylesheetfile", "com/mycompany/app/javadoc/css/stylesheet.css" );
@@ -1028,6 +1032,14 @@
         content = readFile( stylesheetfile );
         assertTrue( content.indexOf( "/* Custom Javadoc style sheet in project */" ) != -1 );
 
+        optionsContent = readFile( options );
+        assertTrue( optionsContent.indexOf( "-stylesheetfile" ) != -1 );
+        File stylesheetResource =
+            new File( getBasedir(),
+                      "src/test/resources/unit/stylesheetfile-test/src/main/resources/com/mycompany/app/javadoc/css/stylesheet.css" );
+        assertTrue( optionsContent.indexOf( "'" + stylesheetResource.getAbsolutePath().replaceAll( "\\\\", "/" )
+            + "'" ) != -1 );
+
         // stylesheetfile defined in a javadoc plugin dependency
         setVariableValueToObject( mojo, "stylesheetfile", "com/mycompany/app/javadoc/css2/stylesheet.css" );
         mojo.execute();
@@ -1035,6 +1047,11 @@
         content = readFile( stylesheetfile );
         assertTrue( content.indexOf( "/* Custom Javadoc style sheet in artefact */" ) != -1 );
 
+        optionsContent = readFile( options );
+        assertTrue( optionsContent.indexOf( "-stylesheetfile" ) != -1 );
+        assertTrue( optionsContent
+                                  .indexOf( "'" + stylesheetfile.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) != -1 );
+
         // stylesheetfile defined as file
         File css =
             new File( getBasedir(),
@@ -1044,6 +1061,14 @@
 
         content = readFile( stylesheetfile );
         assertTrue( content.indexOf( "/* Custom Javadoc style sheet as file */" ) != -1 );
+
+        optionsContent = readFile( options );
+        assertTrue( optionsContent.indexOf( "-stylesheetfile" ) != -1 );
+        stylesheetResource =
+            new File( getBasedir(),
+                      "src/test/resources/unit/stylesheetfile-test/src/main/resources/com/mycompany/app/javadoc/css3/stylesheet.css" );
+        assertTrue( optionsContent.indexOf( "'" + stylesheetResource.getAbsolutePath().replaceAll( "\\\\", "/" )
+            + "'" ) != -1 );
     }
 
     /**
@@ -1064,12 +1089,17 @@
         File helpfile =
             new File( getBasedir(), "target/test/unit/helpfile-test/target/site/apidocs/help-doc.html" );
 
+        File options = new File( getBasedir(), "target/test/unit/helpfile-test/target/site/apidocs/options" );
+
         // helpfile by default
         mojo.execute();
 
         String content = readFile( helpfile );
         assertTrue( content.indexOf( "<!-- Generated by javadoc" ) != -1 );
 
+        String optionsContent = readFile( options );
+        assertTrue( optionsContent.indexOf( "-helpfile" ) == -1 );
+
         // helpfile defined in a javadoc plugin dependency
         setVariableValueToObject( mojo, "helpfile", "com/mycompany/app/javadoc/helpfile/help-doc.html" );
         mojo.execute();
@@ -1077,14 +1107,37 @@
         content = readFile( helpfile );
         assertTrue( content.indexOf( "<!--  Help file from artefact -->" ) != -1 );
 
+        optionsContent = readFile( options );
+        assertTrue( optionsContent.indexOf( "-helpfile" ) != -1 );
+        File help = new File( getBasedir(), "target/test/unit/helpfile-test/target/site/apidocs/help-doc.html" );
+        assertTrue( optionsContent.indexOf( "'" + help.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) != -1 );
+
+        // helpfile defined as a project resource
+        setVariableValueToObject( mojo, "helpfile", "com/mycompany/app/javadoc/helpfile2/help-doc.html" );
+        mojo.execute();
+
+        content = readFile( helpfile );
+        assertTrue( content.indexOf( "<!--  Help file from file -->" ) != -1 );
+
+        optionsContent = readFile( options );
+        assertTrue( optionsContent.indexOf( "-helpfile" ) != -1 );
+        help =
+            new File( getBasedir(),
+                      "src/test/resources/unit/helpfile-test/src/main/resources/com/mycompany/app/javadoc/helpfile2/help-doc.html" );
+        assertTrue( optionsContent.indexOf( "'" + help.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) != -1 );
+
         // helpfile defined as file
-        File css =
+        help =
             new File( getBasedir(),
                       "src/test/resources/unit/helpfile-test/src/main/resources/com/mycompany/app/javadoc/helpfile2/help-doc.html" );
-        setVariableValueToObject( mojo, "helpfile", css.getAbsolutePath() );
+        setVariableValueToObject( mojo, "helpfile", help.getAbsolutePath() );
         mojo.execute();
 
         content = readFile( helpfile );
         assertTrue( content.indexOf( "<!--  Help file from file -->" ) != -1 );
+
+        optionsContent = readFile( options );
+        assertTrue( optionsContent.indexOf( "-helpfile" ) != -1 );
+        assertTrue( optionsContent.indexOf( "'" + help.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) != -1 );
     }
 }