You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by gn...@apache.org on 2009/10/16 11:35:27 UTC

svn commit: r825823 - in /felix/trunk/karaf: assembly/pom.xml manual/pom.xml manual/src/fallback/manual.pdf manual/src/styles/docbook-fo.xsl manual/src/xslt/ manual/src/xslt/extract.xsl pom.xml

Author: gnodet
Date: Fri Oct 16 09:35:27 2009
New Revision: 825823

URL: http://svn.apache.org/viewvc?rev=825823&view=rev
Log:
Change a bit the manual generation so that it can we also fallback to a dummy pdf in case of an error, and it also provides an easier way to switch to something else than prince if needed

Added:
    felix/trunk/karaf/manual/src/fallback/manual.pdf
    felix/trunk/karaf/manual/src/xslt/
    felix/trunk/karaf/manual/src/xslt/extract.xsl
Removed:
    felix/trunk/karaf/manual/src/styles/docbook-fo.xsl
Modified:
    felix/trunk/karaf/assembly/pom.xml
    felix/trunk/karaf/manual/pom.xml
    felix/trunk/karaf/pom.xml

Modified: felix/trunk/karaf/assembly/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/assembly/pom.xml?rev=825823&r1=825822&r2=825823&view=diff
==============================================================================
--- felix/trunk/karaf/assembly/pom.xml (original)
+++ felix/trunk/karaf/assembly/pom.xml Fri Oct 16 09:35:27 2009
@@ -331,14 +331,12 @@
                                     <artifactId>manual</artifactId>
                                     <type>pdf</type>
                                     <outputDirectory>target/dependencies</outputDirectory>
-                                    <destFileName>manual.pdf</destFileName>
                                 </artifactItem>
                                 <artifactItem>
                                     <groupId>org.apache.felix.karaf</groupId>
                                     <artifactId>manual</artifactId>
                                     <type>html</type>
                                     <outputDirectory>target/dependencies</outputDirectory>
-                                    <destFileName>manual.html</destFileName>
                                 </artifactItem>
                             </artifactItems>
                         </configuration>

Modified: felix/trunk/karaf/manual/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/manual/pom.xml?rev=825823&r1=825822&r2=825823&view=diff
==============================================================================
--- felix/trunk/karaf/manual/pom.xml (original)
+++ felix/trunk/karaf/manual/pom.xml Fri Oct 16 09:35:27 2009
@@ -35,6 +35,10 @@
 
   <properties>
       <must-succeed>false</must-succeed>
+      
+      <manual.dir>${project.build.directory}/manual</manual.dir>
+      <manual>${manual.dir}/manual-${project.version}</manual>
+      <svn.root>${project.scm.connection}</svn.root>
   </properties>
 
   <build>
@@ -45,47 +49,74 @@
         <version>1.2</version>
         <executions>
             <execution>
+                <id>preprocess</id>
                 <configuration>
                     <tasks>
                         <taskdef name="if" classname="net.sf.antcontrib.logic.IfTask" classpathref="maven.plugin.classpath"/>
                         <taskdef name="for" classname="net.sf.antcontrib.logic.ForTask" classpathref="maven.plugin.classpath"/>
                         <taskdef name="trycatch" classname="net.sf.antcontrib.logic.TryCatchTask" classpathref="maven.plugin.classpath"/>
                         <property name="ant.regexp.regexpimpl" value="org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp" />
-                        <property name="manual.dir" value="target/site/manual" />
-                        <property name="manual" value="${manual.dir}/manual-${project.version}.html" />
                         <mkdir dir="${manual.dir}"/>
                         <trycatch property="error">
                             <try>
                                 <get src="http://cwiki.apache.org/confluence/display/FELIX/Karaf+Users%27+Guide+in+one+page"
-                                     dest="${manual}" />
+                                     dest="${manual}.temp" />
                                 <for list="1,2,3,4,5,6,7,8,9,10" param="letter">
                                     <sequential>
                                         <replaceregexp
-                                            file="${manual}"
+                                            file="${manual}.temp"
                                             flags="g"
                                             match='"/confluence/display/FELIX/([^"]*)\+([^"+]*)"'
                                             replace='"/confluence/display/FELIX/\1\2"' />
                                     </sequential>
                                 </for>
                                 <replaceregexp
-                                    file="${manual}"
+                                    file="${manual}.temp"
                                     flags="g"
                                     match='"/confluence/display/FELIX/([^"]*)"'
                                     replace='"#KarafUsers%27Guideinonepage-\1"' />
                                 <replaceregexp
-                                    file="${manual}"
+                                    file="${manual}.temp"
                                     flags="g"
                                     match='"/confluence/([^"]*)"'
                                     replace='"http://cwiki.apache.org/confluence/\1"' />
+                                <replaceregexp
+                                    file="${manual}.temp"
+                                    flags="g"
+                                    match='&gt;top&lt;/a&gt;'
+                                    replace='&gt;&lt;/a&gt;' />
+                                <java classname="org.ccil.cowan.tagsoup.CommandLine"
+                                      classpathref="maven.plugin.classpath"
+                                      fork="true"
+                                      output="${manual}.temp2"
+                                      logError="true">
+                                    <arg value="${manual}.temp" />
+                                </java>
+                                <xslt in="${manual}.temp2" out="${manual}.html"
+                                      style="${basedir}/src/xslt/extract.xsl">
+                                    <param name="stylesheet" expression="${basedir}/src/styles/print.css"/>
+                                </xslt>
+                                <exec executable="prince">
+                                    <arg value="${manual}.html"/>
+                                    <arg value="${manual}.pdf"/>
+                                </exec>
+                                <replace file="${manual}.html" 
+                                         token="${basedir}/src/styles/print.css" 
+                                         value="${svn.root}/src/styles/print.css" />
+                                <replace file="${manual}.html" token="scm:svn:" value="" />
                             </try>
                             <catch>
                                 <if>
                                     <equals arg1="${must-succeed}" arg2="true"/>
                                     <then>
+                                        <echo>ERROR: ${error}</echo>
                                         <fail>${error}</fail>
                                     </then>
                                     <else>
-                                        <copy file="src/fallback/manual.html" tofile="${manual}" />
+                                        <echo>ERROR: ${error}</echo>
+                                        <echo>Falling back to dummy manuals</echo>
+                                        <copy file="src/fallback/manual.html" tofile="${manual}.html" />
+                                        <copy file="src/fallback/manual.pdf" tofile="${manual}.pdf" />
                                     </else>
                                 </if>
                             </catch>
@@ -98,54 +129,8 @@
                 <phase>generate-resources</phase>
             </execution>
          </executions>
-          <dependencies>
-              <dependency>
-                  <groupId>ant-contrib</groupId>
-                  <artifactId>ant-contrib</artifactId>
-                  <version>1.0b3</version>
-              </dependency>
-              <dependency>
-                  <groupId>ant</groupId>
-                  <artifactId>ant-optional</artifactId>
-                  <version>1.5.3-1</version>
-              </dependency>
-         </dependencies>
-    </plugin>
-
-     <plugin>
-        <groupId>org.apache.camel</groupId>
-        <artifactId>maven-html-to-pdf</artifactId>
-        <version>2.0.0</version>
-        <executions>
-          <execution>
-            <goals>
-              <goal>compile</goal>
-            </goals>
-            <phase>compile</phase>
-          </execution>
-        </executions>    
-        <configuration>
-          <page>file://${basedir}/target/site/manual/manual-${project.version}.html</page>
-          <head><![CDATA[ 
-              <link href="file:${basedir}/src/styles/print.css" rel="stylesheet" type="text/css" />
-              <style type="text/css">
-                @page :left {
-                  @top-left {
-                    content: "Apache Felix Karaf ${pom.version} Developer's Manual";
-                  }
-                }
-              </style>
-          ]]></head>
-          <replaceToken><![CDATA[
-              >top</a>
-          ]]></replaceToken>
-          <replaceValue><![CDATA[
-              ></a>
-          ]]></replaceValue>
-          <errorOnConverionFailure>${must-succeed}</errorOnConverionFailure>
-          <errorOnDownloadFailure>${must-succeed}</errorOnDownloadFailure>
-        </configuration>
       </plugin>
+
       <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>build-helper-maven-plugin</artifactId>
@@ -158,11 +143,14 @@
             </goals>
             <configuration>
               <artifacts>
-                <!-- Don't need to attach PDF here because the html-to-pdf plugin did that already -->
                 <artifact>
-                  <file>${project.build.directory}/site/manual/manual-${project.version}.html</file>
+                  <file>${manual}.html</file>
                   <type>html</type>
                 </artifact>
+                <artifact>
+                  <file>${manual}.pdf</file>
+                  <type>pdf</type>
+                </artifact>
               </artifacts>
             </configuration>
           </execution>

Added: felix/trunk/karaf/manual/src/fallback/manual.pdf
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/manual/src/fallback/manual.pdf?rev=825823&view=auto
==============================================================================
Files felix/trunk/karaf/manual/src/fallback/manual.pdf (added) and felix/trunk/karaf/manual/src/fallback/manual.pdf Fri Oct 16 09:35:27 2009 differ

Added: felix/trunk/karaf/manual/src/xslt/extract.xsl
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/manual/src/xslt/extract.xsl?rev=825823&view=auto
==============================================================================
--- felix/trunk/karaf/manual/src/xslt/extract.xsl (added)
+++ felix/trunk/karaf/manual/src/xslt/extract.xsl Fri Oct 16 09:35:27 2009
@@ -0,0 +1,46 @@
+<?xml version="1.0"?>
+<!--
+  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.
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+                xmlns:html="http://www.w3.org/1999/xhtml"
+                version="1.0"> 
+    <xsl:param name="stylesheet"/>
+    <xsl:template match="/">
+        <html xmlns="http://www.w3.org/1999/xhtml">
+            <head>
+                <link rel="stylesheet" type="text/css">
+                    <xsl:attribute name="href"><xsl:value-of select="$stylesheet"/></xsl:attribute>
+                </link>
+                <style type="text/css">
+                    @page :left {
+                      @top-left {
+                        content: "Apache Felix Karaf ${pom.version} User's Manual";
+                      }
+                    }
+                </style>
+            </head>
+            <body>
+                <xsl:apply-templates select=".//html:div[@class='wiki-content']" />
+            </body>
+        </html>
+    </xsl:template>
+    <xsl:template match="@*|node()">
+        <xsl:copy>
+            <xsl:apply-templates select="@*|node()"/>
+        </xsl:copy>
+    </xsl:template>
+</xsl:stylesheet>

Modified: felix/trunk/karaf/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/pom.xml?rev=825823&r1=825822&r2=825823&view=diff
==============================================================================
--- felix/trunk/karaf/pom.xml (original)
+++ felix/trunk/karaf/pom.xml Fri Oct 16 09:35:27 2009
@@ -42,11 +42,11 @@
         <module>client</module>
         <module>management</module>
         <module>webconsole</module>
+        <module>manual</module>
         <module>assembly</module>
         <module>demos</module>
         <module>itests</module>
         <module>tooling</module>
-        <module>manual</module>
     </modules>
 
     <scm>
@@ -764,6 +764,11 @@
                             <artifactId>ant-optional</artifactId>
                             <version>1.5.3-1</version>
                         </dependency>
+                        <dependency>
+                            <groupId>org.ccil.cowan.tagsoup</groupId>
+                            <artifactId>tagsoup</artifactId>
+                            <version>1.2</version>
+                        </dependency>
                     </dependencies>
                 </plugin>
             </plugins>