2

I am trying to convert my application to use Java 11 and the java module system, but am having difficulty discovering which "requires" statements to add to my module-info.java. I am currently getting the error "The project was not built since its build path is incomplete. Cannot find the class file for org.locationtech.jts.geom.Envelope. Fix the build path then try building this project".

I have searched through https://github.com/geotools/geotools, but I cannot find any hints regarding which modules expose which packages. For example there is a module "org.geotools.tile_client", but searching that in the repository gets zero hits (so I assume the geotools modules are not handled via config files?).

The geotools Javadoc is unfortunately also not helpful, as geotools is not yet using named modules.

https://docs.geotools.org/stable/userguide/tutorial/quickstart/java11.html mentioned using the same requires as the ones declared in my POM, but for my project requireing (gt-shapefile, gt-swing, gt-tile-client, gt-epsg-hsql, gt-grid) this resulted in the error:

The project was not built since its build path is incomplete. Cannot find the class file for org.opengis.referencing.crs.CoordinateReferenceSystem. Fix the build path then try building this project

Through digging down through the maven dependencies, I found a few more which I now explicitely require too. This brought me past a few more errors.

requires org.geotools.opengis;
requires org.geotools.referencing;
requires org.geotools.coverage;
requires org.geotools.main;
requires org.geotools.render;
requires org.geotools.epsg_hsql;
requires org.geotools.shapefile;
requires org.geotools.grid;
requires org.geotools.tile_client;
requires org.geotools.swing;
requires org.geotools.http;

However, I did find a module which doesnt seem to want to work (gt-cql, dependency of gt-render). requires org.geotools.cql cannot be resolved.

So, as asked at the top, how do I discover the correct Java 11 module names for my GeoTools project? And is there a specific hint as to which module I should require in order to get rid of the org.locationtech.jts.geom.Envelope problem?

Luke Turner
  • 324
  • 1
  • 4
  • 22

1 Answers1

2

Took a while to come to this, but I have come to the following solution thanks to the jar --describe-module command from Is it possible to mix Java 8 and Java 9 source code in the same project without using compiler flags?.

  1. Using mvn dependency:copy-dependencies copies all .jar files to target/dependency.

  2. In target/dependency, create a file "module-report.cmd" with the following content.:

    > module-report.txt ( for %%f in (%~dp0*.jar) do ( jar --file=%%f --describe-module ) )

Its just running the "jar --file=... --describe-module" command on every jar file, outputting it to module-report.txt.

  1. Run module-report.cmd to generate module-report.txt

The contents of the text file contain all of the module information, including contained packages, requires declarations, everything.

Using that report I could then simply search for the packages I couldn't access and easily get the name of the module they were contained in.

Luke Turner
  • 324
  • 1
  • 4
  • 22