Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add module names for better Java 9/Jigsaw support #274

Merged
merged 2 commits into from Mar 27, 2018

Conversation

Projects
None yet
3 participants
@lossyrob
Copy link
Member

lossyrob commented Mar 23, 2018

The Jigsaw module system requires that downstream users of JTS using the module system declare JTS as a module requirement. JTS acts as an automatic module, since it is not compiled with a module-info.java. Without this change, module users would have to reference the requirement for JTS by specifying the JAR name with the fully qualified version; this is unwieldy, will trigger necessary updates when updating the JTS version, and could cause errors when transitive dependencies rely on other versions of JTS.

This change utilizes the technique of putting the module name in the manifest, so that libraries declaring modules can refer to JTS with more friendly, version-less names, e.g.:

// module-info.java for project org.foo.baz

module org.foo.baz {
  requires org.locationtech.jts;            // jts-core
  requires org.locationtech.jts.io;         // jts-io-common
  requires org.locationtech.jts.io.oracle;  // jts-io-ora
  requires org.locationtech.jts.io.sde;     // jts-io-sde
}

Testing Instructions

To verify this work, I defined a Foo.java file and a manifest-info.java file, as follows:

// Foo.java

package org.foo.baz;

import org.locationtech.jts.JTSVersion;
import org.locationtech.jts.io.ParseException;
import org.locationtech.jts.algorithm.distance.DistanceToPoint;
import org.locationtech.jts.io.geojson.GeoJsonConstants;

public class Foo {
  public static void main(String[] args)
  {
    ParseException e = new ParseException("asdf");
    DistanceToPoint d = new DistanceToPoint();
    System.out.println(JTSVersion.CURRENT_VERSION);
    System.out.println(GeoJsonConstants.NAME_GEOMETRIES);
  }
}
// module-info.java

module org.foo.baz {
  requires org.locationtech.jts;
  requires org.locationtech.jts.io;
}

I then compiled and ran Foo as a module:

> mkdir mods
> javac --module-path ./modules/core/target/jts-core-1.15.1-SNAPSHOT.jar:./modules/io/common/target/jts-io-common-1.15.1-SNAPSHOT.jar \
        -d mods/foo \
        module-info.java \
        Foo.java
> java --module-path mods:./modules/core/target/jts-core-1.15.1-SNAPSHOT.jar:./modules/io/common/target/jts-io-common-1.15.1-SNAPSHOT.jar -m org.foo.baz/org.foo.baz.Foo

Expected output:

1.15.0
geometries

This is building JTS with java 8 against commit 3fb74b6

Added maven properties required for building against mvn 3.5.3 and Ja…
…va 9

Signed-off-by: lossyrob <rdemanuele@gmail.com>

@lossyrob lossyrob force-pushed the lossyrob:java-9-jigsaw branch from 6555edf to 6dc0a94 Mar 23, 2018

<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>org.locationtech.jts.io.orcale</Automatic-Module-Name>

This comment has been minimized.

Copy link
@dsmiley

This comment has been minimized.

Copy link
@lossyrob

lossyrob Mar 23, 2018

Author Member

Thanks!

Add module names for better Java 9/Jigsaw support
Signed-off-by: lossyrob <rdemanuele@gmail.com>

@lossyrob lossyrob force-pushed the lossyrob:java-9-jigsaw branch from 6dc0a94 to 8dd5804 Mar 23, 2018

@jodygarnett jodygarnett merged commit 181003a into locationtech:master Mar 27, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.