camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r566751 - in /activemq/camel/trunk/tooling: camel-manual/ maven/maven-html-to-pdf/ maven/maven-html-to-pdf/src/main/java/org/apache/camel/maven/ maven/maven-html-to-pdf/src/main/resources/
Date Thu, 16 Aug 2007 15:38:50 GMT
Author: chirino
Date: Thu Aug 16 08:38:49 2007
New Revision: 566751

URL: http://svn.apache.org/viewvc?view=rev&rev=566751
Log:
Renaming the maven-html-to-docbook module to maven-html-to-pdf

Removed:
    activemq/camel/trunk/tooling/maven/maven-html-to-pdf/src/main/java/org/apache/camel/maven/GenerateDocBookMojo.java
    activemq/camel/trunk/tooling/maven/maven-html-to-pdf/src/main/resources/docbook.xsl
Modified:
    activemq/camel/trunk/tooling/camel-manual/pom.xml
    activemq/camel/trunk/tooling/maven/maven-html-to-pdf/pom.xml
    activemq/camel/trunk/tooling/maven/maven-html-to-pdf/src/main/java/org/apache/camel/maven/ConfluenceToPDFMojo.java

Modified: activemq/camel/trunk/tooling/camel-manual/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/tooling/camel-manual/pom.xml?view=diff&rev=566751&r1=566750&r2=566751
==============================================================================
--- activemq/camel/trunk/tooling/camel-manual/pom.xml (original)
+++ activemq/camel/trunk/tooling/camel-manual/pom.xml Thu Aug 16 08:38:49 2007
@@ -32,36 +32,20 @@
   <name>Camel Manual</name>
   <description>The Camel Manual which generates a HTML and PDF representation of the
manual.</description>
 
-  <repositories>
-    <repository>
-      <id>agilejava</id>
-      <name>AgileJava</name>
-      <url>http://agilejava.com/maven/</url>
-    </repository>
-  </repositories>
-  <pluginRepositories>
-    <pluginRepository>
-      <id>agilejava</id>
-      <name>AgileJava</name>
-      <url>http://agilejava.com/maven/</url>
-    </pluginRepository>
-  </pluginRepositories>
-
-
   <build>
     <plugins>
 
      <plugin>
         <groupId>org.apache.camel</groupId>
-        <artifactId>maven-html-to-docbook</artifactId>
+        <artifactId>maven-html-to-pdf</artifactId>
         <executions>
           <execution>
             <goals>
-              <goal>confluenceToPDF</goal>
+              <goal>compile</goal>
             </goals>
-            <phase>site</phase>
+            <phase>compile</phase>
           </execution>
-        </executions>        
+        </executions>    
         <configuration>
           <page>http://cwiki.apache.org/confluence/display/CAMEL/Book+In+One+Page</page>
           <head><![CDATA[ 
@@ -76,107 +60,6 @@
           ]]></head>
         </configuration>
       </plugin>      
-      <!--
-      <plugin>
-        <groupId>org.apache.camel</groupId>
-        <artifactId>maven-html-to-docbook</artifactId>
-        <executions>
-          <execution>
-            <goals>
-              <goal>htmlToDocbook</goal>
-            </goals>
-            <phase>site</phase>
-          </execution>
-        </executions>        
-        <configuration>
-          <baseURL>http://cwiki.apache.org/CAMEL/</baseURL>
-          <title>Camel</title>
-          <subtitle>User Guide</subtitle>     
-          <resources>
-              <resource>book-introduction.html</resource>
-              <resource>book-architecture.html</resource>
-              <resource>book-enterprise-integration-patterns.html</resource>
-              <resource>book-getting-started.html</resource>
-              <resource>book-pattern-appendix.html</resource>
-              <resource>book-component-appendix.html</resource>
-          </resources>
-          <authors>
-              <author>James Strachan</author>
-              <author>Hiram Chirino</author>
-              <author>Rob Davies</author>
-          </authors>          
-        </configuration>
-      </plugin>      
-      <plugin>
-        <groupId>com.agilejava.docbkx</groupId>
-        <artifactId>docbkx-maven-plugin</artifactId>
-        <version>2.0.3-SNAPSHOT</version>
-        <executions>
-          <execution>
-			<id>execution1</id>
-            <goals>
-              <goal>generate-html</goal>
-            </goals>
-            <phase>site</phase>
-            <configuration>
-               <targetDirectory>${basedir}/target/site/book/html</targetDirectory>
-            </configuration>			
-          </execution>
-          <execution>
-			<id>execution2</id>
-            <goals>
-              <goal>generate-pdf</goal>
-            </goals>
-            <phase>site</phase>
-            <configuration>
-               <targetDirectory>${basedir}/target/site/book/pdf</targetDirectory>
-            </configuration>				
-          </execution>		
-          <execution>
-			<id>execution3</id>
-            <goals>
-              <goal>generate-manpages</goal>
-            </goals>
-            <phase>site</phase>
-            <configuration>
-               <targetDirectory>${basedir}/target/site/book/manpage</targetDirectory>
-            </configuration>				
-          </execution>			    
-        </executions>
-        <dependencies>
-          <dependency>
-            <groupId>org.docbook</groupId>
-            <artifactId>docbook-xml</artifactId>
-            <version>4.4</version>
-            <scope>runtime</scope>
-          </dependency>
-        </dependencies>
-
-        <configuration>
-          <foCustomization>${basedir}/src/styles/docbook-fo.xsl</foCustomization>
-          <includes>manual.xml</includes>
-
-          <chunkedOutput>true</chunkedOutput>
-
-          <entities>
-            <entity>
-              <name>version</name>
-              <value>${version}</value>
-            </entity>
-          </entities>
-
-
-          
-          <sourceDirectory>${basedir}/target/docbkx/docbkx-source</sourceDirectory>
-          
-
-          <headerRule>0</headerRule>
-          <footerRule>0</footerRule>
-          <draftMode>0</draftMode>
-          <bodyFontFamily>Helvetica</bodyFontFamily>
-        </configuration>
-      </plugin>
-      -->
     </plugins>
   </build>
 </project>

Modified: activemq/camel/trunk/tooling/maven/maven-html-to-pdf/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/tooling/maven/maven-html-to-pdf/pom.xml?view=diff&rev=566751&r1=566750&r2=566751
==============================================================================
--- activemq/camel/trunk/tooling/maven/maven-html-to-pdf/pom.xml (original)
+++ activemq/camel/trunk/tooling/maven/maven-html-to-pdf/pom.xml Thu Aug 16 08:38:49 2007
@@ -27,22 +27,13 @@
 
   <artifactId>maven-html-to-pdf</artifactId>
   <packaging>maven-plugin</packaging>
-  <name>Camel :: Html to Docbook Plugin</name>
+  <name>Camel :: Html to Pdf Plugin</name>
 
   <dependencies>
     <dependency>
       <groupId>jtidy</groupId>
       <artifactId>jtidy</artifactId>
       <version>4aug2000r7-dev</version>
-    </dependency>
-    <dependency>
-      <groupId>commons-logging</groupId>
-      <artifactId>commons-logging</artifactId>
-      <scope>test</scope>
-    </dependency>    
-    <dependency>
-      <groupId>commons-logging</groupId>
-      <artifactId>commons-logging-api</artifactId>
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>

Modified: activemq/camel/trunk/tooling/maven/maven-html-to-pdf/src/main/java/org/apache/camel/maven/ConfluenceToPDFMojo.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/tooling/maven/maven-html-to-pdf/src/main/java/org/apache/camel/maven/ConfluenceToPDFMojo.java?view=diff&rev=566751&r1=566750&r2=566751
==============================================================================
--- activemq/camel/trunk/tooling/maven/maven-html-to-pdf/src/main/java/org/apache/camel/maven/ConfluenceToPDFMojo.java
(original)
+++ activemq/camel/trunk/tooling/maven/maven-html-to-pdf/src/main/java/org/apache/camel/maven/ConfluenceToPDFMojo.java
Thu Aug 16 08:38:49 2007
@@ -24,12 +24,9 @@
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.PrintWriter;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
 import java.net.URL;
 
 import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.TransformerFactoryConfigurationError;
@@ -42,26 +39,24 @@
 import org.w3c.dom.NodeList;
 import org.w3c.tidy.Tidy;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 
+import org.codehaus.plexus.util.cli.CommandLineException;
 import org.codehaus.plexus.util.cli.CommandLineUtils;
 import org.codehaus.plexus.util.cli.Commandline;
-import org.codehaus.plexus.util.cli.Commandline.Argument;
 import org.codehaus.plexus.util.cli.StreamConsumer;
+import org.codehaus.plexus.util.cli.Commandline.Argument;
 
 /**
- * Goal which extracts the content html page and converts to PDF using Prince
+ * Goal which extracts the content div from the html page and converts to PDF
+ * using Prince
  * 
- * @goal confluenceToPDF
- * @phase process-sources
+ * @goal compile
+ * @phase compile
  */
 public class ConfluenceToPDFMojo extends AbstractMojo {
 
-    private static final transient Log LOG = LogFactory.getLog(ConfluenceToPDFMojo.class);
-
     /**
      * The URL to the confluence page to convert.
      * 
@@ -72,13 +67,6 @@
     private String page;
 
     /**
-     * Location of the work directory.
-     * 
-     * @parameter expression="${project.build.directory}/site/manual"
-     */
-    private String workDir;
-
-    /**
      * The output file name for the pdf.
      * 
      * @parameter expression="${pdf}"
@@ -100,40 +88,36 @@
      */
     private String head;
 
+    /**
+     * The first div with who's class matches the contentDivClass will be
+     * assumed to be the content section of the HTML and is what will be used as
+     * the content in the PDF.
+     * 
+     * @parameter default-value="wiki-content"
+     */
+    private String contentDivClass = "wiki-content";
+
+    /**
+     * Arguments that should be passed to the prince html to pdf processor.
+     * 
+     * @parameter
+     */
+    private String[] princeArgs;
+
     public void execute() throws MojoExecutionException {
-        File outputDir = new File(workDir);
+        File outputDir = new File(pdf).getParentFile();
         if (!outputDir.exists()) {
             outputDir.mkdirs();
         }
-
         try {
-
             // Download
             String content = downloadContent();
+
             // Store
             storeHTMLFile(content);
+
             // Run Prince
-            getLog().info("Converting to PDF with prince...");
-            Commandline cl = new Commandline("prince");
-            Argument arg = new Argument();
-            arg.setValue(getHTMLFileName());
-            cl.addArg(arg);
-            arg = new Argument();
-            arg.setValue(getPDFFileName());
-            cl.addArg(arg);
-
-            StreamConsumer out = new StreamConsumer() {
-                public void consumeLine(String line) {
-                    System.out.println("prince: " + line);
-                }
-            };
-
-            int rc = CommandLineUtils.executeCommandLine(cl, out, out);
-            if (rc == 0) {
-                getLog().info("Stored: " + getPDFFileName());
-            } else {
-                throw new MojoExecutionException("PDF Conversion failed rc=" + rc);
-            }
+            convert();
 
         } catch (MojoExecutionException e) {
             throw e;
@@ -142,6 +126,40 @@
         }
     }
 
+    private void convert() throws CommandLineException, MojoExecutionException {
+        getLog().info("Converting to PDF with prince...");
+        Commandline cl = new Commandline("prince");
+        Argument arg;
+
+        if (princeArgs != null) {
+            for (int i = 0; i < princeArgs.length; i++) {
+                arg = new Argument();
+                arg.setValue(princeArgs[i]);
+                cl.addArg(arg);
+            }
+        }
+
+        arg = new Argument();
+        arg.setValue(getHTMLFileName());
+        cl.addArg(arg);
+        arg = new Argument();
+        arg.setValue(getPDFFileName());
+        cl.addArg(arg);
+
+        StreamConsumer out = new StreamConsumer() {
+            public void consumeLine(String line) {
+                System.out.println("prince: " + line);
+            }
+        };
+
+        int rc = CommandLineUtils.executeCommandLine(cl, out, out);
+        if (rc == 0) {
+            getLog().info("Stored: " + getPDFFileName());
+        } else {
+            throw new MojoExecutionException("PDF Conversion failed rc=" + rc);
+        }
+    }
+
     private String getPDFFileName() {
         return pdf;
     }
@@ -173,8 +191,7 @@
         return name + ".html";
     }
 
-    private String downloadContent() throws IOException, TransformerFactoryConfigurationError,
TransformerException,
-        MojoExecutionException {
+    private String downloadContent() throws IOException, TransformerFactoryConfigurationError,
TransformerException, MojoExecutionException {
 
         getLog().info("Downloading: " + page);
         URL url = new URL(page);
@@ -185,7 +202,7 @@
             Node node = nodeList.item(i);
             NamedNodeMap nm = node.getAttributes();
             Node attr = nm.getNamedItem("class");
-            if (attr != null && attr.getNodeValue().equalsIgnoreCase("wiki-content"))
{
+            if (attr != null && attr.getNodeValue().equalsIgnoreCase(contentDivClass))
{
                 // Write the wiki-content div to the content variable.
                 ByteArrayOutputStream contentData = new ByteArrayOutputStream(1024 * 100);
                 TransformerFactory tFactory = TransformerFactory.newInstance();
@@ -196,7 +213,7 @@
                 return content;
             }
         }
-        throw new MojoExecutionException("The '" + page + "' page did not have a <div
class=\"wiki-content\"> element.");
+        throw new MojoExecutionException("The '" + page + "' page did not have a <div
class=\"" + contentDivClass + "\"> element.");
     }
 
 }



Mime
View raw message