在module-info.java中找不到所需的模块

时间:2018-12-10 04:40:07

标签: java java-module java-11 openjfx module-info

在运行gradle时,找不到我在module-info.java中声明的所有必需模块:

/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;
}

文件夹结构:

enter image description here

2 个答案:

答案 0 :(得分:1)

您可能需要确保modify the compileJava task为:

compileJava {
    inputs.property("moduleName", moduleName)
    doFirst {
        options.compilerArgs = [
            '--module-path', classpath.asPath,
        ]
        classpath = files()  
    }
}

答案 1 :(得分:0)

在最近的Gradle版本中(因为6.4表示Internet;我在6.5上进行了测试),所以可以更简洁地说:

java {
    modularity.inferModulePath = true
}

再次,也请参见:https://guides.gradle.org/building-java-9-modules/