【发布时间】:2021-12-31 09:16:14
【问题描述】:
我很难将我的自定义 jar 添加到 gwt 编译器。
我已经检查了大量的互联网,但找不到答案。
我找到了将 module.gwt.xml 文件添加到此自定义 jar 库并将其导入我的 gwt 应用 app.gwt.xml 的解决方案,如下所示:<inherits name="com.ia.ia"/>
但这将使我的自定义 java 库 gwt 知道,这对我来说是反模式。因为我将使用 gwt 破坏后端公共库(这只是 UI 细节)。
我想遵循 <source path='maintenance'/> 条目的方法,但我只能为本地 java 类配置它。我不知道如何对外部 jar 执行此操作。
请帮忙
以下是我已经完成的步骤:
我已将源插件添加到我的自定义 jar 的 pom.xml 中,如下所示:
<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>
所以自定义 jar 构建会生成 2 个 jar,正常的和带有源的。
我已将依赖项添加到我的 gwt 项目 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>
当我编译 gwt 时出现错误:
[INFO] [ERROR] Line 16: No source code is available for type com.ia.maintenance.api.network.wifi.WifiSecurityType;你忘了继承一个必需的模块吗?
这是我的 gwt UI 应用模块文件:
<?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>
自定义 jar 库没有任何 module.gwt.xml 文件,因为我不想用前端细节破坏简单的后端 jar。
所以我需要在gwt ui app中配置它。
也许一些 maven 插件会从此自定义 jar 库中获取源 *.java 文件并将其放在目标目录中,例如:target/classes/com.ia.ia.maintenance 以便 gwt 编译器可以拾取它?
【问题讨论】: