Using the "Building Java 9 Modules" in Eclipse Oxygen - guava cannot be resolved to a module

buildship
eclipse

(Peter Vittali) #1

Hi, I am new to gradle and the java module system.
I can compile and run the mentioned guide , more precisely the samples in subdir 2-all-modules on Linux Mint 18.2, Gradle 4.7 and java oracle 10.0.1 from the command line.

Inside Eclipse Oxygen.3a Release (4.7.3a), however, I have compile errors:

module-info.java:

module org.gradle.actors {
exports org.gradle.actors;
requires guava; // Error: guava cannot be resolved to a module
}

And the build.gradle says:


dependencies {
implementation ‘com.google.guava:guava:22.0’
testImplementation ‘junit:junit:4.12’
}

If my understanding of the interaction between gradle and Eclipse is correct, this dependency causes the guava lib to end up on the classpath, under “Project and External Dependencies” in the Eclipse Java Build Path dialogue.

If my understanding of java modules is correct, then this cannot work, because the named module ‘org.gradle.actors’ cannot read any type from guava which is part of the unnamed module.

In the Module properties dialogue in Eclipse, I can now check:

Preformatted textDefines one or more modules

This will put guava on the module path as an automatic module. The project then compiles in Eclipse.
However, if I refresh the gradle project inside Eclipse, this modification ( the checkbox) will be reversed and the Eclipse doesn’t compile, while the gradle project run from the cli still compiles as expected.

So how can I use java modules toegether with buildship in Eclipse ?

Thanks and regards
Peter


(Peter Vittali) #2

In reply to my own post, see