Support building docs on Windows.

This commit is contained in:
dcramer
2013-02-26 15:39:31 -06:00
parent b5b5e13e42
commit a7b6609016
9 changed files with 68 additions and 23 deletions

View File

@@ -17,6 +17,11 @@ How Tos
Release Notes
=============
clouddocs-maven-plugin 1.7.2-SNAPSHOT
============================================================
- Support building docs on Windows.
clouddocs-maven-plugin 1.7.1
============================================================
- Support pdfFilenameBase parameter. Use this parameter to provide an alternative name for the pdf automatically generated when producing webhelp output. By default the base name of the pdf is the base name of the input xml file.

View File

@@ -20,6 +20,7 @@ import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;
import org.apache.maven.plugin.MojoExecutionException;
import org.xml.sax.SAXException;
import org.xml.sax.InputSource;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
@@ -31,6 +32,7 @@ import javax.xml.transform.URIResolver;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.sax.SAXSource;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -40,6 +42,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -408,7 +411,7 @@ public abstract class PDFMojo extends AbstractFoMojo {
File imageDirectory = getImageDirectory();
File calloutDirectory = new File (imageDirectory, "callouts");
transformer.setParameter("docbook.infile",sourceDocBook.getAbsolutePath());
transformer.setParameter("docbook.infile",sourceDocBook.getAbsolutePath().replaceAll("\\\\","/"));
transformer.setParameter("source.directory",sourceDirectory);
transformer.setParameter("compute.wadl.path.from.docbook.path",computeWadlPathFromDocbookPath);
@@ -460,7 +463,7 @@ public abstract class PDFMojo extends AbstractFoMojo {
//transformer.setParameter("docbook.infile",sourceDocBook.getAbsolutePath());
String srcFilename = sourceDocBook.getName();
getLog().info("SOURCE FOR COVER PAGE: "+this.projectBuildDirectory+"/docbkx/"+srcFilename);
transformer.setParameter("docbook.infile", this.projectBuildDirectory+"/docbkx/"+srcFilename);
transformer.setParameter("docbook.infile", this.projectBuildDirectory.replaceAll("\\\\","/")+"/docbkx/"+srcFilename);
transformer.transform (new StreamSource(coverImageTemplate), new StreamResult(coverImage));
}
catch (TransformerConfigurationException e)
@@ -480,7 +483,12 @@ public abstract class PDFMojo extends AbstractFoMojo {
throws MojoExecutionException {
String pathToPipelineFile = "classpath:/pdf.xpl"; //use "classpath:/path" for this to work
Source source = super.createSource(inputFilename, sourceFile, filter);
String sourceFileNameNormalized = "file:///" + sourceFile.getAbsolutePath().replaceAll("\\\\","/");
//from super
final InputSource inputSource = new InputSource(sourceFileNameNormalized);
Source source = new SAXSource(filter, inputSource);
//Source source = super.createSource(inputFilename, sourceFile, filter);
Map map=new HashMap<String, String>();
String sysSecurity=System.getProperty("security");
@@ -488,7 +496,16 @@ public abstract class PDFMojo extends AbstractFoMojo {
if(null!=sysSecurity && !sysSecurity.isEmpty()){
security=sysSecurity;
}
map.put("targetDirectory", this.getTargetDirectory().getParentFile().getAbsolutePath());
String targetDirString = "";
try{
targetDirString = this.getTargetDirectory().getParentFile().getCanonicalPath().replaceAll("\\\\","/");
}catch(Exception e){
getLog().info("Exceptional!" + e);
}
map.put("targetDirectory", targetDirString);
map.put("security", security);
map.put("canonicalUrlBase", canonicalUrlBase);
map.put("replacementsFile", replacementsFile);

View File

@@ -1,5 +1,6 @@
package com.rackspace.cloud.api.docs;
import java.net.*;
import java.io.File;
import java.io.IOException;
import java.io.StringReader;
@@ -21,6 +22,7 @@ import javax.xml.transform.URIResolver;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.sax.SAXSource;
import org.apache.maven.project.MavenProject;
@@ -706,7 +708,12 @@ public abstract class WebHelpMojo extends AbstractWebhelpMojo {
throws MojoExecutionException {
String pathToPipelineFile = "classpath:/webhelp.xpl"; //use "classpath:/path" for this to work
Source source = super.createSource(inputFilename, sourceFile, filter);
String sourceFileNameNormalized = "file:///" + sourceFile.getAbsolutePath().replaceAll("\\\\","/");
//from super
final InputSource inputSource = new InputSource(sourceFileNameNormalized);
Source source = new SAXSource(filter, inputSource);
//Source source = super.createSource(inputFilename, sourceFile, filter);
Map<String, String> map=new HashMap<String, String>();
@@ -715,6 +722,14 @@ public abstract class WebHelpMojo extends AbstractWebhelpMojo {
if(null!=sysWebhelpWar && !sysWebhelpWar.isEmpty()){
webhelpWar=sysWebhelpWar;
}
String targetDirString = "";
try{
targetDirString = this.getTargetDirectory().getParentFile().getCanonicalPath().replaceAll("\\\\","/");
}catch(Exception e){
getLog().info("Exceptional!" + e);
}
map.put("targetDirectory", this.getTargetDirectory().getParentFile().getAbsolutePath());
map.put("webhelp.war", webhelpWar);
map.put("publicationNotificationEmails", publicationNotificationEmails);
@@ -796,7 +811,10 @@ public abstract class WebHelpMojo extends AbstractWebhelpMojo {
//targetExtQueryFile can tell us where the html will be built. We pass this absolute path to the
//pipeline so that the copy-and-transform-image step can use it to calculate where to place the images.
map.put("targetDir", baseDir.getAbsolutePath()+File.separator+"figures");
map.put("targetDir", baseDir.getAbsolutePath()+File.separator+"figures");
// String targetDirFiguresString = baseDir.getAbsolutePath()+File.separator+"figures";
// map.put("targetDir", targetDirFiguresString.replaceAll("\\\\","/").replace("file:/", "file:///"));
// getLog().info("~~~~~~~~FOOBAR~~~~~~~~~~~~~~~~:");
// getLog().info("~~~~~~~~baseDir:" + baseDir);

View File

@@ -208,8 +208,6 @@ public class PDFBuilder {
final File sourceFile = new File(sourceDirectory+"/"+inputFilename);
File targetFile = new File(autopdfTargetDirectory, targetFilename);
//getLog().info("Processing input file: " + inputFilename);
final XMLReader reader = factory.newSAXParser().getXMLReader();
// configure XML reader
reader.setEntityResolver(resolver);
@@ -464,8 +462,8 @@ public class PDFBuilder {
// transformer.setParameter("docbook.infile", sourceFilePath);
getLog().info("SOURCE FOR COVER PAGE: "+this.projectBuildDirectory+"/"+inputFilename);
transformer.setParameter("docbook.infile", this.projectBuildDirectory+"/"+inputFilename);
getLog().info("SOURCE FOR COVER PAGE: "+this.projectBuildDirectory.replaceAll("\\\\","/")+"/"+inputFilename);
transformer.setParameter("docbook.infile", this.projectBuildDirectory.replaceAll("\\\\","/")+"/"+inputFilename);
transformer.transform (new StreamSource(coverImageTemplate), new StreamResult(coverImage));
}
@@ -1022,8 +1020,9 @@ public class PDFBuilder {
throws MojoExecutionException {
String pathToPipelineFile = "classpath:/pdf.xpl"; //use "classpath:/path" for this to work
String sourceFileNameNormalized = "file:///" + sourceFile.getAbsolutePath().replaceAll("\\\\","/");
//from super
final InputSource inputSource = new InputSource(sourceFile.getAbsolutePath());
final InputSource inputSource = new InputSource(sourceFileNameNormalized);
Source source = new SAXSource(filter, inputSource);
Map<String,String> localMap = new HashMap<String,String>(map);

View File

@@ -70,7 +70,13 @@ public class CopyAndTransformXProcStep extends DefaultStep {
private URI getTargetDirectoryURI() {
RuntimeValue target = getOption(_target);
URI uri = null;
if (target != null) {
String targetFixed = FilenameUtils.normalizeNoEndSeparator(target.getString()).replaceAll("\\\\","/").replace("file:/", "file:///");
uri = target.getBaseURI().resolve(targetFixed);
uri = target.getBaseURI().resolve(FilenameUtils.normalizeNoEndSeparator(target.getString()));
}
@@ -81,7 +87,7 @@ public class CopyAndTransformXProcStep extends DefaultStep {
RuntimeValue target = getOption(_targetHtmlContentDir);
URI uri = null;
if (target != null) {
uri = target.getBaseURI().resolve(target.getString());
uri = target.getBaseURI().resolve(target.getString().replaceAll("\\\\","/"));
}
return uri;
}

View File

@@ -40,7 +40,7 @@
<xsl:for-each
select="distinct-values($wadls/wadl/@href)">
<xsl:variable name="checksum" select="rax:checksum(.)"/>
<xsl:variable name="newhref" select="concat('file://',$project.build.directory,'/generated-resources/xml/xslt/',$checksum,'-',replace(., '^(.*/)?([^/]+)$', '$2'))"/>
<xsl:variable name="newhref" select="concat('file:///',translate($project.build.directory,'\','/'),'/generated-resources/xml/xslt/',$checksum,'-',replace(., '^(.*/)?([^/]+)$', '$2'))"/>
<!-- Only add this wadl to the list if the new wadl does not already exist -->
<xsl:choose>
<xsl:when test="unparsed-text-available(.)">

View File

@@ -54,7 +54,7 @@
<xsl:apply-templates/>
<xsl:result-document
href="{$base.dir}/bookinfo.xml"
href="file:///{$base.dir}/bookinfo.xml"
method="xml" indent="yes" encoding="UTF-8">
<products xmlns="">
<latestpdf><xsl:value-of select="$pdfFilenameBaseCalculated"/>-latest.pdf</latestpdf><!-- <xsl:choose> -->
@@ -127,7 +127,7 @@
</products>
</xsl:result-document>
<xsl:result-document
href="{$base.dir}/webapp/WEB-INF/bookinfo.properties"
href="file:///{$base.dir}/webapp/WEB-INF/bookinfo.properties"
method="xml" indent="no" encoding="UTF-8">
<c:result xmlns:c="http://www.w3.org/ns/xproc-step">
warprefix=<xsl:value-of select="$warprefix"/>

View File

@@ -85,7 +85,7 @@ pdfsuffix=<xsl:if test="not($security = 'external') and not($security = '') and
</p:xslt>
<p:store name="store" encoding="utf-8" method="text" media-type="text">
<p:with-option name="href" select="concat('file://',
<p:with-option name="href" select="concat('file:///',
(if ($targetDirectory != '') then $targetDirectory else $project.build.directory),
(if ($targetDirectory = '') then '/docbkx' else ''),
'/autopdf/pdf.properties')"/>

View File

@@ -234,7 +234,7 @@
<p:pipe step="params" port="parameters"/>
</p:variable>
<p:store>
<p:with-option name="href" select="concat('file://',$project.build.directory,'/',$inputSrcFile,'-invalid-', current-dateTime(),'.xml')"/>
<p:with-option name="href" select="concat('file:///',$project.build.directory,'/',$inputSrcFile,'-invalid-', current-dateTime(),'.xml')"/>
<p:input port="source">
<p:pipe port="source" step="main"/>
</p:input>
@@ -691,7 +691,7 @@
</p:iteration-source>
<p:store encoding="utf-8" indent="true" omit-xml-declaration="false">
<p:with-option name="href"
select="concat('file://',$project.build.directory,'/generated-resources/xml/xslt/',$checksum,'-',replace(base-uri(/*), '^(.*/)?([^/]+)$', '$2'))"
select="concat('file:///',$project.build.directory,'/generated-resources/xml/xslt/',$checksum,'-',replace(base-uri(/*), '^(.*/)?([^/]+)$', '$2'))"
/>
</p:store>
</p:for-each>
@@ -737,7 +737,7 @@
</cx:replace-text>
<p:store encoding="utf-8" indent="true" omit-xml-declaration="false">
<p:with-option name="href"
select="concat('file://',$targetDirectory,'/',$inputSrcFile)"
select="concat('file:///',$targetDirectory,'/',$inputSrcFile)"
/>
</p:store>
</p:group>
@@ -906,7 +906,7 @@
<p:load name="preprocess.xsl">
<p:with-option name="href"
select="concat('file://',
select="concat('file:///',
(if ($targetDirectory != '') then $targetDirectory else $project.build.directory),
(if ($targetDirectory = '') then '/docbkx' else ''),
'/cloud/war/preprocess.xsl')" >
@@ -1028,7 +1028,7 @@
<p:load name="bookinfo.xsl">
<p:with-option name="href"
select="concat('file://',
select="concat('file:///',
(if ($targetDirectory != '') then $targetDirectory else $project.build.directory),
(if ($targetDirectory = '') then '/docbkx' else ''),
'/cloud/webhelp/bookinfo.xsl')" >
@@ -1278,8 +1278,8 @@
<p:pipe step="copy-and-transform-images-step" port="source"/>
</p:input>
<p:with-option name="target" select="concat('file://',$target.html.content.dir, '/figures')"/>
<p:with-option name="targetHtmlContentDir" select="concat('file://',$target.html.content.dir)"/>
<p:with-option name="target" select="concat('file:///',$target.html.content.dir, '/figures')"/>
<p:with-option name="targetHtmlContentDir" select="concat('file:///',$target.html.content.dir)"/>
<p:with-option name="inputFileName" select="concat($input.docbook.file,'')"/>
<p:with-option name="outputType" select="concat($output.type,'')"/>
<p:with-option name="fail-on-error" select="concat($strict.image.validation,'')"/>