Skip to content

Feature/fop 2x compatibility#145

Open
sepe81 wants to merge 5 commits into
mimil:masterfrom
sepe81:feature/fop-2x-compatibility
Open

Feature/fop 2x compatibility#145
sepe81 wants to merge 5 commits into
mimil:masterfrom
sepe81:feature/fop-2x-compatibility

Conversation

@sepe81

@sepe81 sepe81 commented May 29, 2026

Copy link
Copy Markdown

Migrates the PDF rendering pipeline from Apache FOP 1.1 (with its Avalon Framework dependency) to FOP 2.11.

Changes

  • Replace fop artifact with fop-core and remove avalon-framework-impl dependency
  • Replace deprecated FopFactory.newInstance() and DefaultConfigurationBuilder (Avalon) with FopConfParser / FopFactoryBuilder (FOP 2.x API)
  • Extract buildInlineConfig() (package-private) to isolate template rendering from factory creation and enable unit testing
  • Preserve baseUrl resolution behaviour: base URI is now passed directly to FopConfParser for both inline and external config paths
  • Set StreamSource.systemId on the FO input so FOP can resolve relative URIs within the document
  • Remove AvalonMavenBridgeLogger (Avalon logging bridge no longer needed; FOP 2.x routes through Commons Logging → SLF4J)
  • Upgrade maven-compiler-plugin to 3.11.0 and bump source/target from 1.4 to 8

Tests

Replaces Avalon-Configuration-based assertions with direct tests against the new API surface: createFopFactory() and buildInlineConfig(), including a regression test that verifies relative URI resolution against the configured baseUrl.

sepe81 added 5 commits May 29, 2026 20:26
- Replace fop:1.1 with fop-core:2.11 in all poms
- Remove Avalon framework dependencies (gone in FOP 2.x)
- Rewrite AbstractFoMojo: replace loadFOPConfig() (Avalon-based) with
  createFopFactory() using FopConfParser / FopFactory.newInstance(URI, InputStream)
- Remove FOUserAgent.setBaseURL() call (removed in FOP 2.x); use
  StreamSource.setSystemId() for base URI resolution instead
- Delete AvalonMavenBridgeLogger (no longer needed)
- Update DocbkxPdfMojoTest to test new createFopFactory() API
- Upgrade maven-compiler-plugin 2.0.2->3.11.0 with source/target=8
  (Java 11 rejects source/target=1.4)
- Upgrade maven-plugin-plugin 3.2->3.9.0
  (3.2 crashes with ArrayIndexOutOfBoundsException on Java 11)
Route both inline and external FOP configurations through FopConfParser
with an explicit base URI, so that baseUrl (derived from the source
DocBook XML's parent directory in adjustTransformer) is applied as the
factory's base URI in both branches. Previously the external-config
branch silently dropped baseUrl, causing FOP to resolve relative
<fo:external-graphic src="..."/> URIs against the xconf's directory
instead of the source XML directory — a regression vs the pre-2.x
behaviour where FOUserAgent.setBaseURL(baseUrl) was set unconditionally.

Specify StandardCharsets.UTF_8 when bridging the generated config XML
through IOUtils.toInputStream(String) and InputStreamReader, instead of
relying on Charset.defaultCharset(). On non-UTF-8 platforms (Windows
CP1252) the deprecated no-charset overload mis-encodes any non-ASCII
content in font family names or font file paths, breaking FOP's XML
parser with MalformedByteSequenceException.

Extract the StringTemplate config rendering into a package-private
buildInlineConfig() so unit tests can assert that targetResolution and
sourceResolution actually flow into the generated XML. The previous
test suite only checked that createFopFactory() returned non-null,
which would silently pass even if template.setAttribute() calls were
removed entirely. Add:
- testBuildInlineConfigDefaultsOmitResolutions: no stray
  <target-resolution> / <source-resolution> elements when unset.
- testBuildInlineConfigPropagatesResolutions: configured resolutions
  appear in the generated XML.
- testCreateFopFactoryAppliesBaseUrl: FOUserAgent.resolveURI()
  anchors relative URIs under the configured baseUrl, guarding against
  the regression described above.

Loosen baseUrl visibility from private to package-private to allow the
new behavioural test. Also guard against a NullPointerException when
the fonts.stg classpath resource is missing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant