Issue
I struggle with adding my custom jar to gwt compiler.
I've check tons of internet and can not find answer.
I found solution to add module.gwt.xml file to this custom jar library and import it in my gwt app app.gwt.xml as follow: <inherits name="com.ia.ia"/>
But this will make my custom java library gwt aware and this is anti pattern for me. As I will spoil backend common library with gwt (which is just UI detail).
I would like to follow approach with <source path='maintenance'/>
entry but I can configure it only for local java classes. I do not know how to do this for external jar.
Please help
Here are steps I've done already:
I've added source plugin to pom.xml of my custom jar as follow:
<plugin>
<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>
so the custom jar builds generate 2 jars, normal and with sources.
I've added dependency to my gwt project ui/pom.xml
<dependency>
<groupId>com.ia</groupId>
<artifactId>ia-maintenance-api</artifactId>
<version>${qiasphere-maintenance.version}</version>
</dependency>
<dependency>
<groupId>com.ia</groupId>
<artifactId>ia-maintenance-api</artifactId>
<version>${ia-maintenance.version}</version>
<classifier>sources</classifier>
</dependency>
When I do compile gwt I am getting error:
[INFO] [ERROR] Line 16: No source code is available for type com.ia.maintenance.api.network.wifi.WifiSecurityType; did you forget to inherit a required module?
this is my gwt UI app module file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.9.0//EN"
"http://gwtproject.org/doctype/2.9.0/gwt-module.dtd">
<module rename-to="app">
<inherits name='com.google.gwt.user.User'/>
<inherits name="com.google.gwt.editor.Editor"/>
<inherits name="com.google.gwt.i18n.I18N"/>
<inherits name='com.github.nalukit.nalu.Nalu'/>
<inherits name='com.github.nalukit.nalu.plugin.elemental2.NaluPluginElemental2'/>
<inherits name='org.dominokit.domino.ui.DominoUI'/>
<inherits name="org.dominokit.rest.Rest"/>
<inherits name="org.jresearch.threetenbp.gwt.time.module"/>
<entry-point class='com.ia.ia.app.ui.APP'/>
<!-- Specify the paths for translatable code (java and java script) -->
<source path='ui'/>
<source path='shared'/>
</module>
custom jar library doesnt have any module.gwt.xml file as I do not wanna spoil simple backend jar with frontend details.
So I need to configure it in gwt ui app.
Maybe some maven plugin that will get source *.java file from this custom jar library and put it in target directory like: target/classes/com.ia.ia.maintenance
so gwt compiler could pick it up?
Solution
You dont need to modify the jar, all you need is to create a gwt.xml file in your own project/client module that has its sources tag points to the pojos package.
What I would do is to create a package in my client module com.ia.ia.maintenance
and add a new gwt.xml there Maintenance.gwt.xml
<?xml version="1.0" encoding="UTF-8"?>
<module>
<source path="" />
</module>
now in your own application gwt.xml you inherit this new module.
Answered By - Ahmad Bawaneh
Answer Checked By - David Marino (JavaFixing Volunteer)