You are viewing a plain text version of this content. The canonical link for it is here.
Posted to doxia-commits@maven.apache.org by lt...@apache.org on 2008/02/17 19:20:09 UTC

svn commit: r628526 - in /maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer: AbstractDocumentRenderer.java pdf/fo/FoPdfRenderer.java

Author: ltheussl
Date: Sun Feb 17 10:20:08 2008
New Revision: 628526

URL: http://svn.apache.org/viewvc?rev=628526&view=rev
Log:
Copy resources so the pdf plugin finds images

Modified:
    maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/AbstractDocumentRenderer.java
    maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/fo/FoPdfRenderer.java

Modified: maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/AbstractDocumentRenderer.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/AbstractDocumentRenderer.java?rev=628526&r1=628525&r2=628526&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/AbstractDocumentRenderer.java (original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/AbstractDocumentRenderer.java Sun Feb 17 10:20:08 2008
@@ -22,6 +22,7 @@
 import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -40,6 +41,7 @@
 
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 
+import org.codehaus.plexus.util.DirectoryScanner;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
@@ -320,4 +322,61 @@
             sink.flush();
         }
     }
+
+    /**
+     * Copies the contents of the resource directory to an output folder.
+     *
+     * @param outputDirectory the destination folder.
+     * @throws java.io.IOException if any.
+     */
+    protected void copyResources( File outputDirectory )
+            throws IOException
+    {
+        File resourcesDirectory = new File( getBaseDir(), "resources" );
+
+        if ( resourcesDirectory.isDirectory() && outputDirectory.isDirectory() )
+        {
+            copyDirectory( resourcesDirectory, outputDirectory );
+        }
+    }
+
+    /**
+     * Copy content of a directory, excluding scm-specific files.
+     *
+     * @param source directory that contains the files and sub-directories to be copied.
+     * @param destination destination folder.
+     * @throws java.io.IOException if any.
+     */
+    protected void copyDirectory( File source, File destination )
+            throws IOException
+    {
+        if ( source.isDirectory() && destination.isDirectory() )
+        {
+            DirectoryScanner scanner = new DirectoryScanner();
+
+            String[] includedResources = {"**/**"};
+
+            scanner.setIncludes( includedResources );
+
+            scanner.addDefaultExcludes();
+
+            scanner.setBasedir( source );
+
+            scanner.scan();
+
+            List includedFiles = Arrays.asList( scanner.getIncludedFiles() );
+
+            for ( Iterator j = includedFiles.iterator(); j.hasNext(); )
+            {
+                String name = (String) j.next();
+
+                File sourceFile = new File( source, name );
+
+                File destinationFile = new File( destination, name );
+
+                FileUtils.copyFile( sourceFile, destinationFile );
+            }
+        }
+    }
+
 }

Modified: maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/fo/FoPdfRenderer.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/fo/FoPdfRenderer.java?rev=628526&r1=628525&r2=628526&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/fo/FoPdfRenderer.java (original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/fo/FoPdfRenderer.java Sun Feb 17 10:20:08 2008
@@ -204,6 +204,9 @@
 
         sink.endDocument();
 
+        // copy resources, images, etc.
+        copyResources( outputDirectory );
+
         generatePdf( outputFOFile, pdfOutputFile );
     }