From f6a46a8a88288c99b0392f7cc55f788cb11eb51c Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Aug 18 2015 10:12:51 +0000 Subject: Port to fop-2.0 --- diff --git a/0001-Fix-itext-dependency.patch b/0001-Fix-itext-dependency.patch index b0a0b99..e2b137c 100644 --- a/0001-Fix-itext-dependency.patch +++ b/0001-Fix-itext-dependency.patch @@ -1,7 +1,7 @@ -From a8a5e181c76fee4f654faae63322e1e5de932192 Mon Sep 17 00:00:00 2001 +From 1f2f116f430d3ecf215f092518c73dd84d33ced0 Mon Sep 17 00:00:00 2001 From: Stanislav Ochotnicky Date: Mon, 29 Apr 2013 11:37:12 +0200 -Subject: [PATCH 1/4] Fix itext dependency +Subject: [PATCH 1/5] Fix itext dependency --- doxia-modules/doxia-module-itext/pom.xml | 2 +- diff --git a/0002-Update-to-Plexus-Container-1.5.5.patch b/0002-Update-to-Plexus-Container-1.5.5.patch index 80a8b4b..a338268 100644 --- a/0002-Update-to-Plexus-Container-1.5.5.patch +++ b/0002-Update-to-Plexus-Container-1.5.5.patch @@ -1,7 +1,7 @@ -From 4aa783ca170c7e18710d1928a728c6f91592f3ee Mon Sep 17 00:00:00 2001 +From 96c7615ae82ed30cfb93225bd9f983a8efa1c74e Mon Sep 17 00:00:00 2001 From: Mikolaj Izdebski Date: Wed, 6 Nov 2013 12:46:26 +0100 -Subject: [PATCH 2/4] Update to Plexus Container 1.5.5 +Subject: [PATCH 2/5] Update to Plexus Container 1.5.5 --- .../java/org/apache/maven/doxia/module/AbstractIdentityTest.java | 3 ++- diff --git a/0003-Update-to-Commons-Collections-1.10.patch b/0003-Update-to-Commons-Collections-1.10.patch index 8d97ce0..72bd0f7 100644 --- a/0003-Update-to-Commons-Collections-1.10.patch +++ b/0003-Update-to-Commons-Collections-1.10.patch @@ -1,7 +1,7 @@ -From 948da7364e2e542bb8f0f9b703269162c591ebfa Mon Sep 17 00:00:00 2001 +From be1b2b36cd943cb27e85d4850bf37590a0056822 Mon Sep 17 00:00:00 2001 From: Mikolaj Izdebski Date: Thu, 7 Nov 2013 08:24:01 +0100 -Subject: [PATCH 3/4] Update to Commons Collections 1.10 +Subject: [PATCH 3/5] Update to Commons Collections 1.10 --- doxia-modules/doxia-module-fo/pom.xml | 9 ++++++++- diff --git a/0004-Disable-tests-which-rely-on-ordering-in-set.patch b/0004-Disable-tests-which-rely-on-ordering-in-set.patch index d3e70d5..1458da3 100644 --- a/0004-Disable-tests-which-rely-on-ordering-in-set.patch +++ b/0004-Disable-tests-which-rely-on-ordering-in-set.patch @@ -1,7 +1,7 @@ -From a479cba6bde3262a8326e0cad2d6a0f34af7ed6f Mon Sep 17 00:00:00 2001 +From 143c842ab8a83f3955abde5e5ca98837d4c3a568 Mon Sep 17 00:00:00 2001 From: Michal Srb Date: Wed, 26 Mar 2014 09:58:20 +0100 -Subject: [PATCH 4/4] Disable tests which rely on ordering in set +Subject: [PATCH 4/5] Disable tests which rely on ordering in set These tests fail with Java 8 --- diff --git a/0005-Port-to-fop-2.0.patch b/0005-Port-to-fop-2.0.patch new file mode 100644 index 0000000..fc53df1 --- /dev/null +++ b/0005-Port-to-fop-2.0.patch @@ -0,0 +1,157 @@ +From 2c4cc792744d6a7790d73e419220938bca12b8c2 Mon Sep 17 00:00:00 2001 +From: Michael Simacek +Date: Mon, 17 Aug 2015 17:15:05 +0200 +Subject: [PATCH 5/5] Port to fop-2.0 + +--- + doxia-modules/doxia-module-fo/pom.xml | 2 +- + .../org/apache/maven/doxia/module/fo/FoUtils.java | 58 ++++++---------------- + 2 files changed, 16 insertions(+), 44 deletions(-) + +diff --git a/doxia-modules/doxia-module-fo/pom.xml b/doxia-modules/doxia-module-fo/pom.xml +index 0d89e4f..2897eb3 100644 +--- a/doxia-modules/doxia-module-fo/pom.xml ++++ b/doxia-modules/doxia-module-fo/pom.xml +@@ -85,7 +85,7 @@ under the License. + + org.apache.xmlgraphics + fop +- 0.95 ++ 2.0 + + + log4j +diff --git a/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoUtils.java b/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoUtils.java +index 0e7efc1..c398eaf 100644 +--- a/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoUtils.java ++++ b/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoUtils.java +@@ -24,6 +24,7 @@ import java.io.File; + import java.io.FileOutputStream; + import java.io.IOException; + import java.io.OutputStream; ++import java.net.URI; + import java.util.Date; + + import javax.xml.transform.Result; +@@ -38,6 +39,7 @@ import org.apache.fop.apps.FOPException; + import org.apache.fop.apps.FOUserAgent; + import org.apache.fop.apps.Fop; + import org.apache.fop.apps.FopFactory; ++import org.apache.fop.apps.FopFactoryBuilder; + import org.apache.fop.apps.MimeConstants; + import org.apache.maven.doxia.document.DocumentModel; + import org.codehaus.plexus.util.IOUtil; +@@ -52,28 +54,11 @@ import org.codehaus.plexus.util.StringUtils; + */ + public class FoUtils + { +- /** To reuse the FopFactory **/ +- private static final FopFactory FOP_FACTORY = FopFactory.newInstance(); +- + /** To reuse the TransformerFactory **/ + private static final TransformerFactory TRANSFORMER_FACTORY = TransformerFactory.newInstance(); + +- /** +- * Converts an FO file to a PDF file using FOP. +- * +- * @param fo the FO file, not null. +- * @param pdf the target PDF file, not null. +- * @param resourceDir The base directory for relative path resolution, could be null. +- * If null, defaults to the parent directory of fo. +- * @param documentModel the document model to add PDF metadatas like author, title and keywords, could be null. +- * @throws javax.xml.transform.TransformerException In case of a conversion problem. +- * @since 1.1.1 +- */ +- public static void convertFO2PDF( File fo, File pdf, String resourceDir, DocumentModel documentModel ) +- throws TransformerException +- { +- FOUserAgent foUserAgent = getDefaultUserAgent( fo, resourceDir ); + ++ private static void prepareUserAgent( FOUserAgent foUserAgent, DocumentModel documentModel ) { + if ( documentModel != null && documentModel.getMeta() != null ) + { + // http://xmlgraphics.apache.org/fop/embedding.html#user-agent +@@ -113,8 +98,6 @@ public class FoUtils + { + foUserAgent.setCreationDate( new Date() ); + } +- +- convertFO2PDF( fo, pdf, resourceDir, foUserAgent ); + } + + /** +@@ -124,16 +107,13 @@ public class FoUtils + * @param pdf the target PDF file, not null. + * @param resourceDir The base directory for relative path resolution, could be null. + * If null, defaults to the parent directory of fo. +- * @param foUserAgent the FOUserAgent to use. +- * May be null, in which case a default user agent will be used. ++ * @param documentModel the document model to add PDF metadatas like author, title and keywords, could be null. + * @throws javax.xml.transform.TransformerException In case of a conversion problem. + * @since 1.1.1 + */ +- public static void convertFO2PDF( File fo, File pdf, String resourceDir, FOUserAgent foUserAgent ) ++ public static void convertFO2PDF( File fo, File pdf, String resourceDir, DocumentModel documentModel ) + throws TransformerException + { +- FOUserAgent userAgent = ( foUserAgent == null ? getDefaultUserAgent( fo, resourceDir ) : foUserAgent ); +- + OutputStream out = null; + try + { +@@ -149,7 +129,11 @@ public class FoUtils + Result res = null; + try + { +- Fop fop = FOP_FACTORY.newFop( MimeConstants.MIME_PDF, userAgent, out ); ++ URI baseURI = getBaseURI( fo, resourceDir ); ++ FopFactory fopFactory = new FopFactoryBuilder( baseURI ).build(); ++ FOUserAgent userAgent = fopFactory.newFOUserAgent(); ++ prepareUserAgent( userAgent, documentModel ); ++ Fop fop = fopFactory.newFop( MimeConstants.MIME_PDF, userAgent, out ); + res = new SAXResult( fop.getDefaultHandler() ); + } + catch ( FOPException e ) +@@ -193,34 +177,22 @@ public class FoUtils + } + + /** +- * Returns a base URL to be used by the FOUserAgent. ++ * Returns a base URI. + * + * @param fo the FO file. + * @param resourceDir the resource directory. +- * @return String. ++ * @return URI. + */ +- private static String getBaseURL( File fo, String resourceDir ) ++ private static URI getBaseURI( File fo, String resourceDir ) + { +- String url = null; +- + if ( resourceDir == null ) + { +- url = "file:///" + fo.getParent() + "/"; ++ return fo.getParentFile().toURI(); + } + else + { +- url = "file:///" + resourceDir + "/"; ++ return new File( resourceDir + "/" ).toURI(); + } +- +- return url; +- } +- +- private static FOUserAgent getDefaultUserAgent( File fo, String resourceDir ) +- { +- FOUserAgent foUserAgent = FOP_FACTORY.newFOUserAgent(); +- foUserAgent.setBaseURL( getBaseURL( fo, resourceDir ) ); +- +- return foUserAgent; + } + + private FoUtils() +-- +2.1.0 + diff --git a/maven-doxia.spec b/maven-doxia.spec index 84f99ed..b43a2fe 100644 --- a/maven-doxia.spec +++ b/maven-doxia.spec @@ -5,7 +5,7 @@ Name: maven-doxia Version: 1.6 -Release: 3%{?dist} +Release: 4%{?dist} Epoch: 0 Summary: Content generation framework License: ASL 2.0 @@ -35,6 +35,9 @@ Patch3: 0003-Update-to-Commons-Collections-1.10.patch # Don't run bad tests which rely on ordering in set (they fail with Java 8) Patch4: 0004-Disable-tests-which-rely-on-ordering-in-set.patch +# Not upstreamable due to higher Java version of fop's dependencies +Patch5: 0005-Port-to-fop-2.0.patch + BuildArch: noarch BuildRequires: maven-local @@ -206,6 +209,7 @@ API documentation for %{name}. %patch2 -p1 %patch3 -p1 %patch4 -p1 +%patch5 -p1 mkdir doxia-core/src/main/java/org/apache/maven/doxia/sink/render cp -p %SOURCE1 doxia-core/src/main/java/org/apache/maven/doxia/sink/render/ @@ -266,6 +270,9 @@ cp -p %SOURCE1 doxia-core/src/main/java/org/apache/maven/doxia/sink/render/ %changelog +* Tue Aug 18 2015 Michael Simacek - 0:1.6-4 +- Port to fop-2.0 + * Wed Jun 17 2015 Fedora Release Engineering - 0:1.6-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild