All the required modules I've declared in module-info.java
are not being found when I run gradle:
/Users/Joseph/eclipse-workspace/CheckMyDigitalFootprint/src/main/java/module-info.java:10: error: module not found: com.jfoenix
requires com.jfoenix;
^
/Users/Joseph/eclipse-workspace/CheckMyDigitalFootprint/src/main/java/module-info.java:11: error: module not found: google.api.client
requires google.api.client;
^
/Users/Joseph/eclipse-workspace/CheckMyDigitalFootprint/src/main/java/module-info.java:12: error: module not found: google.api.services.gmail.v1.rev83
requires google.api.services.gmail.v1.rev83;
^
/Users/Joseph/eclipse-workspace/CheckMyDigitalFootprint/src/main/java/module-info.java:13: error: module not found: google.http.client
requires google.http.client;
^
/Users/Joseph/eclipse-workspace/CheckMyDigitalFootprint/src/main/java/module-info.java:14: error: module not found: google.http.client.jackson2
requires google.http.client.jackson2;
^
/Users/Joseph/eclipse-workspace/CheckMyDigitalFootprint/src/main/java/module-info.java:15: error: module not found: google.oauth.client
requires google.oauth.client;
^
/Users/Joseph/eclipse-workspace/CheckMyDigitalFootprint/src/main/java/module-info.java:16: error: module not found: google.oauth.client.java6
requires google.oauth.client.java6;
^
/Users/Joseph/eclipse-workspace/CheckMyDigitalFootprint/src/main/java/module-info.java:17: error: module not found: google.oauth.client.jetty
requires google.oauth.client.jetty;
^
/Users/Joseph/eclipse-workspace/CheckMyDigitalFootprint/src/main/java/module-info.java:18: error: module not found: java.xml.bind
requires java.xml.bind;
^
/Users/Joseph/eclipse-workspace/CheckMyDigitalFootprint/src/main/java/module-info.java:23: error: module not found: org.json
requires org.json;
module-info.java:
module footprint {
requires com.jfoenix;
requires google.api.client;
requires google.api.services.gmail.v1.rev83;
requires google.http.client;
requires google.http.client.jackson2;
requires google.oauth.client;
requires google.oauth.client.java6;
requires google.oauth.client.jetty;
requires java.xml.bind;
requires transitive javafx.base;
requires javafx.controls;
requires javafx.fxml;
requires transitive javafx.graphics;
requires org.json;
requires java.prefs;
opens checkmydigitalfootprint to javafx.fxml;
exports checkmydigitalfootprint.util;
exports checkmydigitalfootprint;
exports checkmydigitalfootprint.model;
exports checkmydigitalfootprint.view;
}
Folder structure:
In order to declare a module, we need to include the "module-info. java" file to root source code. 1) requires <module>: By default, a module doesn't know other modules present in a module-path. So, it is necessary to add a line in our module-info.
The module declaration ( module-info. java ) needs to go into your source root directory (e.g. src/main/java ). It then has to be among the list of files to compile, so it will get turned into a module descriptor ( module-info. class ).
module-info. java file. It declares the dependencies within the module system and allows the compiler and the runtime to police the boundaries/access violations between the modules in your application.
You probably need to ensure to modify the compileJava
task as :
compileJava {
inputs.property("moduleName", moduleName)
doFirst {
options.compilerArgs = [
'--module-path', classpath.asPath,
]
classpath = files()
}
}
In recent Gradle versions (since 6.4 says the Internet; I tested on 6.5), this can be stated more concisely:
java {
modularity.inferModulePath = true
}
Again, see also: https://guides.gradle.org/building-java-9-modules/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With