Reporting my experience setting up a module-info.java for a project using
FOP.
By way of background, here's the maven dependency tree
[INFO] +- org.apache.xmlgraphics:fop:jar:2.5:compile
[INFO] | +- org.apache.xmlgraphics:fop-util:jar:2.5:compile
[INFO] | +- org.apache.xmlgraphics:fop-events:jar:2.5:compile
[INFO] | | +- com.thoughtworks.qdox:qdox:jar:1.12:compile
[INFO] | | \- org.apache.ant:ant:jar:1.8.2:compile
[INFO] | | \- org.apache.ant:ant-launcher:jar:1.8.2:compile
[INFO] | \- org.apache.xmlgraphics:fop-core:jar:2.5:compile
[INFO] | +- org.apache.xmlgraphics:batik-anim:jar:1.13:compile
[INFO] | | +- org.apache.xmlgraphics:batik-css:jar:1.13:compile
[INFO] | | +- org.apache.xmlgraphics:batik-dom:jar:1.13:compile
[INFO] | | +- org.apache.xmlgraphics:batik-ext:jar:1.13:compile
[INFO] | | +- org.apache.xmlgraphics:batik-parser:jar:1.13:compile
[INFO] | | +-
org.apache.xmlgraphics:batik-shared-resources:jar:1.13:compile
[INFO] | | +- org.apache.xmlgraphics:batik-svg-dom:jar:1.13:compile
[INFO] | | \- org.apache.xmlgraphics:batik-util:jar:1.13:compile
[INFO] | | +-
org.apache.xmlgraphics:batik-constants:jar:1.13:compile
[INFO] | | \- org.apache.xmlgraphics:batik-i18n:jar:1.13:compile
[INFO] | +- org.apache.xmlgraphics:batik-awt-util:jar:1.13:compile
[INFO] | +- org.apache.xmlgraphics:batik-bridge:jar:1.13:compile
[INFO] | | +- org.apache.xmlgraphics:batik-script:jar:1.13:compile
[INFO] | | \- org.apache.xmlgraphics:batik-xml:jar:1.13:compile
[INFO] | +- org.apache.xmlgraphics:batik-extension:jar:1.13:compile
[INFO] | +- org.apache.xmlgraphics:batik-gvt:jar:1.13:compile
[INFO] | +- org.apache.xmlgraphics:batik-transcoder:jar:1.13:compile
[INFO] | | \- org.apache.xmlgraphics:batik-svggen:jar:1.13:compile
[INFO] | +- javax.servlet:servlet-api:jar:2.2:compile
[INFO] | +- org.apache.pdfbox:fontbox:jar:2.0.16:compile
[INFO] | +- javax.media:jai-core:jar:1.1.3:compile
[INFO] | \- com.sun.media:jai-codec:jar:1.1.3:compile
The fop jar packages fop-util, fop-events, and fop-core, so you want either
the all-in-one jar, or the other 3 jars, but not both.
If you have both, you'll get an error like: The package
org.apache.fop.configuration is accessible from more than one module: fop,
fop.core
So which way to go, the fop all-in-one jar. or the other three?
The answer for now at least is to use the fop all-in-one jar. If you were
to try using the other three jars as modules, you get:
Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Modules fop.core and fop.events
export package org.apache.fop.tools to module error.prone.annotations
So here are the requires statements I ended up with:
requires fop;
// deps of org.apache.xmlgraphics:fop-core:jar:2.5
requires batik.anim;
requires batik.css;
requires batik.dom;
requires batik.ext;
requires batik.parser;
requires batik.shared.resources;
requires batik.svg.dom;
requires batik.util;
requires batik.constants;
requires batik.i18n;
requires batik.awt.util;
requires batik.bridge;
//requires batik.script;
requires batik.extension;
requires batik.gvt;
requires batik.transcoder;
requires batik.svggen;
requires org.apache.fontbox; // has an Automatic-Module-Name in its
MANIFEST.MF
//requires jai.core;
//requires jai.codec;
batik.script is commented out, because including it results in the
following error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for
/home/jharrop/.m2/repository/org/apache/xmlgraphics/batik-script/1.13/batik-script-1.13.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Provider
class org.apache.batik.bridge.RhinoInterpreterFactory not in module
Using fop all-in-one but excluding the duplicate classes is a bit of a pain
from a Maven point of view, since you then have to explicitly include the
fop-core deps. Here is what I ended up with:
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<version>2.5</version>
<exclusions>
<!-- exclude duplicate classes -->
<exclusion>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop-util</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop-events</artifactId>
</exclusion>
<!-- other -->
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis-ext</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
</exclusion>
<exclusion>
<groupId>xalan</groupId>
<artifactId>serializer</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- so we need to include fop-core deps directly -->
<!-- batik deps -->
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-anim</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-awt-util</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-bridge</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-extension</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-gvt</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-transcoder</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>fontbox</artifactId>
<version>2.0.19</version>
</dependency>
<!--
<dependency>
<groupId>javax.media</groupId>
<artifactId>jai-core</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>com.sun.media</groupId>
<artifactId>jai-codec</artifactId>
<version>1.1.3</version>
</dependency>
-->