Eclipse Oxygen: how to specify module dependencies

Viewed 1876

I am trying to familiarize myself with Eclipse's support for Java 9 modules. I use Eclipse Oxygen with the Java 9 Support Package from the marketplace and the latest JDK 9 u180.

The problem concerns module dependencies and how to let Eclipse know about them.

My understanding is that in Eclipse a JPMS module corresponds to an Eclipse project. I created three projects aka modules and added the necessary module-info files:

module com.effjava.app {
  requires com.effjava.support;
}

module com.effjava.support {
  exports com.effjava.support.hlp;
  exports com.effjava.support.test;
  exports com.effjava.support.user;

  requires transitive com.effjava.util;
}

module com.effjava.util {
  exports com.effjava.util.cbk;
  exports com.effjava.util.reg;
}

It is a simple top-down dependency chain. The module descriptors are correct; I already succeeded in setting up the same modules in IntelliJ.

My problem is: how do I tell Eclipse that the top modules depend on the bottom ones, e.g. that the middle module com.effjava.support depends on the bottom module com.effjava.util?

I did specify the dependency in the module-info file (via requires transitive) and Eclipse accepts the directive without a complaint. Yet I see an error message when I compile the middle module com.effjava.support. The error message says that a public type from package com.effjava.util.cbk is not visible, despite being exported by module com.effjava.util and required by module com.effjava.support.

screenshot showing project structure and compiler error message

In order to specify the dependency, I exported the content of the bottom module com.effjava.util to a jar file, including the module-info.class. Hence it is a modular jar file.

Then I imported the modular jar file into the com.effjava.support module and added the imported modular jar file to the build path. To no avail.

screenshot of build path

I tried it without an import, just adding the modular jar as an external library. It didn't work either.

The question is: how do I correctly specify module dependencies in Eclipse?

0 Answers
Related