batik-bridge does not declare xmlgraphics-commons dependency

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

batik-bridge does not declare xmlgraphics-commons dependency

Curtis Rueden
Hi everyone,

I maintain some projects which use Batik for reading SVG files [1]. All works very well; thank you very much for this great library!

These projects depend on batik components via Maven. I noticed that batik-bridge requires xmlgraphics-commons, but does not declare it in its POM. So without xmlgraphics-commons on the classpath, there are runtime errors like:

java.lang.NoClassDefFoundError: org/apache/xmlgraphics/java2d/color/DeviceCMYKColorSpace
at org.apache.batik.bridge.SVGShapeElementBridge.createShapePainter(SVGShapeElementBridge.java:117)
at org.apache.batik.bridge.SVGDecoratedShapeElementBridge.createFillStrokePainter(SVGDecoratedShapeElementBridge.java:58)
at org.apache.batik.bridge.SVGDecoratedShapeElementBridge.createShapePainter(SVGDecoratedShapeElementBridge.java:84)
at org.apache.batik.bridge.SVGShapeElementBridge.buildGraphicsNode(SVGShapeElementBridge.java:91)
at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:224)
at org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:171)
at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:82)
at sc.fiji.io.SVG_Reader.run(SVG_Reader.java:53)

If you look at the POM on Maven Central [2], you'll see that xmlgraphics-commons is not one of the dependencies. But if you look at the POM of the release tag [3], you'll see that it is. Apparently there was a similar issue back in 2015, but it was fixed [4].

Similarly, batik-constants seems to be required even at compile time; without it, javac says:

  [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.0:compile (default-compile) on project IO_: Compilation failure
  [ERROR] /Users/curtis/code/fiji/IO/src/main/java/sc/fiji/io/SVG_Reader.java:[53,33] cannot access org.apache.batik.util.XMLConstants
  [ERROR]   class file for org.apache.batik.util.XMLConstants not found

Where the line of code in question has no direct reference to XMLConstants.

(As an aside: in contrast to javac, the Eclipse compiler does not complain about this when batik-constants is missing from the compile-time classpath.)

To work around this problem, we declare batik-constants and xmlgraphics-commons explicitly as dependencies [5].

I am curious if this dependency weirdness is a known issue, and if a fix is planned?

Regards,
Curtis






--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
Did you know ImageJ has a forum? http://forum.imagej.net/