[jboss-svn-commits] JBL Code SVN: r13111 - in labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin: src/main/java/org/jboss/maven/plugins/jdocbook/gen/format and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Jul 5 11:35:35 EDT 2007
Author: steve.ebersole at jboss.com
Date: 2007-07-05 11:35:35 -0400 (Thu, 05 Jul 2007)
New Revision: 13111
Modified:
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/pom.xml
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/BasicFormatHandler.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/PdfFormatHandler.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/TransformerFactory.java
Log:
upgrade to fop-0.93; handle css copying from staging
Modified: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/pom.xml
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/pom.xml 2007-07-05 15:07:43 UTC (rev 13110)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/pom.xml 2007-07-05 15:35:35 UTC (rev 13111)
@@ -191,20 +191,40 @@
<artifactId>saxon</artifactId>
<version>6.5.3</version>
</dependency>
-
- <!-- todo : upgrade this to 0.93 or later once the fox: extension element issues are fixed -->
<dependency>
- <groupId>fop</groupId>
+ <groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
- <version>0.20.5</version>
+ <version>0.93</version>
</dependency>
+ <!-- Batik is used by FOP for SVG, PNG, and TIFF processing -->
<dependency>
<groupId>batik</groupId>
- <artifactId>batik-1.5-fop</artifactId>
- <version>0.20-5</version>
+ <artifactId>batik-css</artifactId>
+ <version>${batikVersion}</version>
+ <scope>runtime</scope>
</dependency>
<dependency>
+ <groupId>batik</groupId>
+ <artifactId>batik-dom</artifactId>
+ <version>${batikVersion}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>batik</groupId>
+ <artifactId>batik-util</artifactId>
+ <version>${batikVersion}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>batik</groupId>
+ <artifactId>batik-xml</artifactId>
+ <version>${batikVersion}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- JAI is used by FOP for GIF and TIFF processing -->
+ <dependency>
<groupId>javax.media</groupId>
<artifactId>jai-core</artifactId>
<version>1.1.3</version>
@@ -222,6 +242,7 @@
<properties>
<doxiaVersion>1.0-alpha-8</doxiaVersion>
<doxiaSiteVersion>1.0-alpha-8</doxiaSiteVersion>
+ <batikVersion>1.6</batikVersion>
</properties>
</project>
Modified: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/BasicFormatHandler.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/BasicFormatHandler.java 2007-07-05 15:07:43 UTC (rev 13110)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/BasicFormatHandler.java 2007-07-05 15:35:35 UTC (rev 13111)
@@ -65,6 +65,8 @@
FileUtils.mkdir( target.getAbsolutePath() );
}
if ( formatting.isImageCopyingRequired() ) {
+ // for now, isImageCopyingRequired() controls image and css copying.
+ // todo : consider renaming (to what though???)
if ( factory.getStagingDirectory().exists() ) {
File imageBase = new File( factory.getStagingDirectory(), "images" );
if ( imageBase.exists() ) {
@@ -75,6 +77,15 @@
throw new RenderingException( "unable to copy images", e );
}
}
+ File cssBase = new File( factory.getStagingDirectory(), "css" );
+ if ( cssBase.exists() ) {
+ try {
+ FileUtils.copyDirectoryStructure( cssBase, target );
+ }
+ catch ( IOException e ) {
+ throw new RenderingException( "unable to copy css", e );
+ }
+ }
}
}
return target;
@@ -115,7 +126,7 @@
transformer.transform( transformationSource, transformationResult );
}
catch ( TransformerException e ) {
- throw new XSLTException( "unable to perform transformation", e );
+ throw new XSLTException( "error performing translation [" + e.getLocationAsString() + "] : " + e.getMessage(), e );
}
finally {
releaseResult( transformationResult );
Modified: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/PdfFormatHandler.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/PdfFormatHandler.java 2007-07-05 15:07:43 UTC (rev 13110)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/PdfFormatHandler.java 2007-07-05 15:35:35 UTC (rev 13111)
@@ -23,12 +23,12 @@
import javax.xml.transform.Result;
import javax.xml.transform.sax.SAXResult;
-import org.apache.avalon.framework.logger.Logger;
-import org.apache.fop.apps.Driver;
-import org.apache.fop.apps.FOPException;
-import org.apache.maven.plugin.logging.Log;
-import org.jboss.maven.plugins.jdocbook.gen.util.Formatting;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.Fop;
+import org.apache.fop.apps.FopFactory;
+import org.apache.fop.apps.MimeConstants;
import org.jboss.maven.plugins.jdocbook.gen.RenderingException;
+import org.jboss.maven.plugins.jdocbook.gen.util.Formatting;
/**
* Special handling for pdf rendering
@@ -43,23 +43,18 @@
protected Result buildResult(File targetFile) throws RenderingException {
getLog().info( "building formatting result [" + targetFile.getAbsolutePath() + "]" );
- prepareFonts();
return new ResultImpl( targetFile );
}
- private void prepareFonts() throws RenderingException {
- // if fonts were specified, then prepare the FOP font metrics configuration
- // : this is the piece that improved dramatically after fop-0.25,
- // which unfortunately we are stuck with for other reasons :(
+ private void prepareFonts(FopFactory fopFactory) throws RenderingException {
+ // todo : need to figure out the best way to deal with fonts overall...
if ( factory.getFontConfig() != null ) {
- org.apache.fop.configuration.Configuration.put( "fontBaseDir", new File( factory.getStagingDirectory(), "fonts" ) );
try {
- new org.apache.fop.apps.Options( factory.getFontConfig() );
+ fopFactory.setUserConfig( factory.getFontConfig() );
}
- catch ( FOPException e ) {
- throw new RenderingException( "unable to properly prepare FOP fonts", e );
+ catch ( Throwable t ) {
+ throw new RenderingException( "unable to properly prepare FOP fonts", t );
}
- org.apache.fop.configuration.Configuration.put( "fontBaseDir", new File( factory.getStagingDirectory(), "fonts" ) );
}
}
@@ -71,14 +66,17 @@
private OutputStream outputStream;
public ResultImpl(File targetFile) throws RenderingException {
- Driver driver = new Driver();
- driver.setLogger( new LoggingBridge( getLog() ) );
- driver.setRenderer( Driver.RENDER_PDF );
-
try {
+ FopFactory fopFactory = FopFactory.newInstance();
+ prepareFonts( fopFactory );
+
outputStream = new BufferedOutputStream( new FileOutputStream( targetFile ) );
- driver.setOutputStream( outputStream );
- setHandler( driver.getContentHandler() );
+
+ FOUserAgent fopUserAgent = fopFactory.newFOUserAgent();
+ fopUserAgent.setProducer( "jDocBook Plugin for Maven" );
+
+ Fop fop = fopFactory.newFop( MimeConstants.MIME_PDF, fopUserAgent, outputStream );
+ setHandler( fop.getDefaultHandler() );
}
catch ( Throwable t ) {
throw new RenderingException( "error building transformation result [" + targetFile.getAbsolutePath() + "]", t );
@@ -86,6 +84,9 @@
}
private void release() {
+ if ( outputStream == null ) {
+ return;
+ }
try {
outputStream.flush();
outputStream.close();
@@ -96,80 +97,4 @@
}
}
- private static class LoggingBridge implements Logger {
-
- private Log mavenLog;
-
- public LoggingBridge(Log mavenLog) {
- this.mavenLog = mavenLog;
- }
-
- public Logger getChildLogger(String arg0) {
- return null;
- }
-
- public void debug(String arg0) {
- mavenLog.debug( arg0 );
- }
-
- public void debug(String arg0, Throwable arg1) {
- mavenLog.debug( arg0, arg1 );
- }
-
- // todo : info logging from FOP is excessively verbose...
-
- public void info(String arg0) {
- mavenLog.info( arg0 );
- }
-
- public void info(String arg0, Throwable arg1) {
- mavenLog.info( arg0, arg1 );
- }
-
- public void warn(String arg0) {
- mavenLog.warn( arg0 );
- }
-
- public void warn(String arg0, Throwable arg1) {
- mavenLog.warn( arg0, arg1 );
- }
-
- public void error(String arg0) {
- mavenLog.error( arg0 );
- }
-
- public void error(String arg0, Throwable arg1) {
- mavenLog.error( arg0, arg1 );
- }
-
- public void fatalError(String arg0) {
- mavenLog.error( arg0 );
- }
-
- public void fatalError(String arg0, Throwable arg1) {
- mavenLog.error( arg0, arg1 );
- }
-
- public boolean isDebugEnabled() {
- return mavenLog.isDebugEnabled();
- }
-
- public boolean isErrorEnabled() {
- return mavenLog.isErrorEnabled();
- }
-
- public boolean isFatalErrorEnabled() {
- return mavenLog.isErrorEnabled();
- }
-
- public boolean isInfoEnabled() {
- return mavenLog.isInfoEnabled();
- }
-
- public boolean isWarnEnabled() {
- return mavenLog.isWarnEnabled();
- }
-
- }
-
}
Modified: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/TransformerFactory.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/TransformerFactory.java 2007-07-05 15:07:43 UTC (rev 13110)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/TransformerFactory.java 2007-07-05 15:35:35 UTC (rev 13111)
@@ -113,6 +113,9 @@
}
private void applyParameters(Transformer transformer) {
+ transformer.setParameter( "fop.extensions", "0" );
+ transformer.setParameter( "fop1.extensions", "1" );
+
if ( transformerParameters == null ) {
return;
}
More information about the jboss-svn-commits
mailing list