Skip to content
Advertisement

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

one can say that, it is a continuation of question
How to “require” module “gwt.user” On Java, JDK17, “module-info.java”, Netbeans, Maven

I am updating my old libraries with module-info.java files.
I have a COMPLEX project named “api-log” dependent on “gwt-user”.
Just for using the 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>

With the module-info.java below:

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

When netbeans runs compile, it builds successfully:

cd C:mecodesGWTapiapi-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:mecodesGWTapiapi-logtarget

--- 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:mecodesGWTapiapi-logtargetclasses
/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:mecodesGWTapiapi-logsrctestresources

--- 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:mecodesGWTapiapi-logtargetapi-log-1.0-SNAPSHOT.jar

--- maven-install-plugin:2.4:install (default-install) @ api-log ---
Installing C:mecodesGWTapiapi-logtargetapi-log-1.0-SNAPSHOT.jar to C:Userstugal.m2repositorycomtugalsanapi-log1.0-SNAPSHOTapi-log-1.0-SNAPSHOT.jar
Installing C:mecodesGWTapiapi-logpom.xml to C:Userstugal.m2repositorycomtugalsanapi-log1.0-SNAPSHOTapi-log-1.0-SNAPSHOT.pom
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time:  1.883 s
Finished at: 2022-04-29T13:39:08+03:00
------------------------------------------------------------------------

However, when I look at the module-info.java file, Netbeans show error:

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

enter image description here

<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>
  • What is the proper way on finding which artifact name one should exclude?
  • What is does the error mean when “com.tugalsan.api.log reads THE package from base”. It cannot be java.base?

Advertisement

Answer

The solution is adding exclusion to dependency 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>

USEFUL VIDEO: https://www.youtube.com/watch?v=xKmv24_2Asw&t=2094s

full code: at github

Advertisement