I tried to locate an example of pom.xml and module-info.java to use fop in an embedded way with JPMS, namely Java-17, but could not find one.
E.g. my code:
FopFactoryBuilder builder = new FopFactoryBuilder(basePath.toUri()).setPageHeight("297mm")
.setPageWidth("210mm");
FopFactory fopFactory = builder.build();
out = new BufferedOutputStream(Files.newOutputStream(r));
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);
Transformer transformer = TransformerFactory.newInstance().newTransformer();
Source src = new StreamSource(fo.toFile());
Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, res);
worked until fop 2.8 with
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<version>2.8</version>
<exclusions>
<exclusion>
<groupId>xalan</groupId>
<artifactId>serializer</artifactId>
</exclusion>
<exclusion>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-script</artifactId>
</exclusion>
<exclusions>
</dependency>
My module-info.java contains
requires Saxon.HE;
requires transitive org.slf4j;
requires java.prefs;
requires fop;
requires xmlgraphics.commons;
requires java.xml;
When upgrading to fop version 2.9 it misses the package org.apache.fop.apps. in compilation.
As I found that solution by trial-and-error, my question is a bit broader: How to embed fop in a JPMS project environment?
Seemingly the classes(
org.apache.fop.apps.*) you are looking for have been abstracted tofop-core, hence adding arequiresdirective for that as a module with version2.9shall get you going.In fact referenced in a few documents and the mailing list threads --
So, it would be better to replace the
requires fopwithBut, the contributors needs to focus further to restructure the common packages to make all these three being used independently and combined by clients or else as shared by you compilation fails with :