如何在 Java、JDK17、"module-info.java"、Netbeans、Maven 上 "require" 模块 "gwt.user"(问题继续)

How to "require" module "gwt.user" On Java, JDK17, "module-info.java", Netbeans, Maven (Problem Continues)

可以说,这是问题的延续

我正在用模块-info.java 文件更新我的旧库。
我有一个名为“api-log”的复杂项目,它依赖于“gwt-user”。
只是为了使用 class com.google.web.bindery.event.shared.UmbrellaException;

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.tugalsan</groupId>
    <artifactId>api-log</artifactId>
    <version>1.0-SNAPSHOT</version>
  
    <dependencies>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>javax.validation</groupId>
                    <artifactId>validation-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.gwt</groupId>
                    <artifactId>gwt-core</artifactId>
                </exclusion>
            </exclusions>
            <version>2.9.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.elemental2</groupId>
            <artifactId>elemental2-dom</artifactId>
            <version>1.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.fusesource.jansi</groupId>
            <artifactId>jansi</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>api-pack</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>api-string</artifactId>
            <version>${project.version}</version>
        </dependency>
        
    </dependencies>
    
    <build>
        <resources> 
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.java</include>
                    <include>**/*.gwt.xml</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.*</include>
                </includes>
            </resource>
        </resources>
        
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.2.1</version>
                    <executions>
                        <execution>
                            <id>attach-sources</id>
                            <phase>package</phase>
                            <goals>
                                <goal>jar-no-fork</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.1</version>
            </plugin>
        </plugins>
    </build>
    
    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
</project>

使用以下模块-info.java:

module com.tugalsan.api.log {
    requires gwt.user;
    requires elemental2.dom;
    requires org.fusesource.jansi;
    requires com.tugalsan.api.pack;
    requires com.tugalsan.api.string;
    exports com.tugalsan.api.log.client;
    exports com.tugalsan.api.log.server;
}

当 netbeans 运行编译时,它构建成功:

cd C:\me\codes\GWT\api\api-log; "JAVA_HOME=C:\Program Files\Eclipse Adoptium\jdk-17.0.2.8-hotspot" cmd /c "\"C:\Program Files\NetBeans-13\netbeans\java\maven\bin\mvn.cmd\" \"-Dmaven.ext.class.path=C:\Program Files\NetBeans-13\netbeans\java\maven-nblib\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 clean install"
Scanning for projects...

------------------------< com.tugalsan:api-log >------------------------
Building api-log 1.0-SNAPSHOT
--------------------------------[ jar ]---------------------------------

--- maven-clean-plugin:2.5:clean (default-clean) @ api-log ---
Deleting C:\me\codes\GWT\api\api-log\target

--- maven-resources-plugin:2.6:resources (default-resources) @ api-log ---
Using 'UTF-8' encoding to copy filtered resources.
Copying 9 resources
Copying 0 resource

--- maven-compiler-plugin:3.10.1:compile (default-compile) @ api-log ---
********************************************************************************************************************************************************************
* Required filename-based automodules detected: [gwt-user-2.9.0.jar, elemental2-dom-1.1.0.jar]. Please don't publish this project to a public artifact repository! *
********************************************************************************************************************************************************************
Changes detected - recompiling the module!
Compiling 8 source files to C:\me\codes\GWT\api\api-log\target\classes
/C:/me/codes/GWT/api/api-log/src/main/java/com/tugalsan/api/log/server/TS_Log.java: Some input files use unchecked or unsafe operations.
/C:/me/codes/GWT/api/api-log/src/main/java/com/tugalsan/api/log/server/TS_Log.java: Recompile with -Xlint:unchecked for details.

--- maven-resources-plugin:2.6:testResources (default-testResources) @ api-log ---
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory C:\me\codes\GWT\api\api-log\src\test\resources

--- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ api-log ---
Changes detected - recompiling the module!

--- maven-surefire-plugin:2.12.4:test (default-test) @ api-log ---

--- maven-jar-plugin:2.4:jar (default-jar) @ api-log ---
Building jar: C:\me\codes\GWT\api\api-log\target\api-log-1.0-SNAPSHOT.jar

--- maven-install-plugin:2.4:install (default-install) @ api-log ---
Installing C:\me\codes\GWT\api\api-log\target\api-log-1.0-SNAPSHOT.jar to C:\Users\tugal\.m2\repository\com\tugalsan\api-log.0-SNAPSHOT\api-log-1.0-SNAPSHOT.jar
Installing C:\me\codes\GWT\api\api-log\pom.xml to C:\Users\tugal\.m2\repository\com\tugalsan\api-log.0-SNAPSHOT\api-log-1.0-SNAPSHOT.pom
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time:  1.883 s
Finished at: 2022-04-29T13:39:08+03:00
------------------------------------------------------------------------

但是,当我查看模块-info.java 文件时,Netbeans 显示错误:

module com.tugalsan.api.log reads package com.google.gwt.core.client from both base and gwt.user

<exclusions>
    <exclusion>
        <groupId>com.google.jsinterop</groupId>
        <artifactId>jsinterop-annotations</artifactId>
    </exclusion>
    <exclusion>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
    </exclusion>
    <exclusion>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
    </exclusion>
    <exclusion>
        <groupId>org.w3c.css</groupId>
        <artifactId>sac</artifactId>
    </exclusion>
</exclusions>

解决方案是添加排除依赖项elemental2.dom

     <dependency>
        <groupId>com.google.elemental2</groupId>
        <artifactId>elemental2-dom</artifactId>
        <exclusions>
            <exclusion>
                <groupId>com.google.jsinterop</groupId>
                <artifactId>base</artifactId>
            </exclusion>
        </exclusions>
        <version>1.1.0</version>
    </dependency>

有用的视频:https://www.youtube.com/watch?v=xKmv24_2Asw&t=2094s