Skip to content
Advertisement

gradle Jigsaw module not found

I try to run a very simple gradle project which uses java 9 modules, but i receive the following error.

JavaScript

Here is it https://github.com/vad0/test_modules. The main class does basically nothing.

JavaScript

It uses only one dependency: HdrHistogram. I included this magic command in build.gradle according to official gradle tutorial https://docs.gradle.org/current/samples/sample_java_modules_multi_project.html.

JavaScript

The whole build.gradle looks like this.

JavaScript

module.info looks like this

JavaScript

I have already read a number of tutorials on Jigsaw and a whole bunch of stackoverflow questions related to it, but still can’t make this simple example work. How do i fix it?

Thank you

Advertisement

Answer

Unfortunately, gradle does not treat every jar as a module (in simple words). If you want to find out how exactly is gradle building the module-path (as opposed to class-path), you probably want to start from here, specifically at the isModuleJar method. It’s pretty easy to understand (though it took me almost two days to set-up gradle and debug the problem out) that the dependency that you are trying to use : gradle says that it is not a module (it isn’t wrong, but I am not sure it is correct either). To make it very correct, gradle will add your dependency to the CLASSPATH, but in the very next line: it will not add your dependency to the module-path, because if fails the filter in isModuleJar.

I do not know if this is a bug or not, or may be this is on purpose, but the solution is easy:

JavaScript

you add it to the path, on purpose. I will flag this as a defect and let’s see what they have to say.

EDIT

Even better, use a plugin that is written by a gradle commiter:

JavaScript

And the easiest option on your case is to do :

JavaScript
Advertisement