GWT Maven 多模块

GWT Maven Multi Module

我创建了一个具有以下结构的 GWT Maven 多模块项目。

核心模块[包含活动、演示者、共享资源] core.gwt.xml 有入口点

core.gwt.xml

<inherits name='com.google.gwt.user.User' />

<!-- We need the JUnit module in the main module, -->
<!-- otherwise eclipse complains (Google plugin bug?) -->

<!--<inherits name='com.google.gwt.junit.JUnit' /> -->

<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->

<!--inherits name='com.google.gwt.user.theme.standard.Standard' /> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- <stylesheet src="styles-global.css"/> -->

<!--GWT-QUERY -->
<!-- <inherits name='com.google.gwt.query.Query'/> -->



<!--SuperDev Mode -->

<!-- add-linker name="xsiframe"/> <set-configuration-property name="devModeRedirectEnabled" 
    value="true"/-->

<set-property name="user.agent" value="gecko1_8,safari" />

<!-- Other module inherits -->

<!-- We need the MVP stuff (Activity and Place -->
<!-- I am also using DepInj with Gin (Inject) -->
<!-- and Resource for client bundle and stuff (not used yet) -->

<inherits name="com.google.gwt.activity.Activity" />
<inherits name="com.google.gwt.place.Place" />
<inherits name="com.google.gwt.inject.Inject" />
<inherits name="com.google.gwt.resources.Resources" />
<inherits name="com.google.gwt.user.Debug" />
<inherits name="org.fusesource.restygwt.RestyGWT"/>

 <!-- gwtbootstrap3 -->
<inherits name="com.template.resources.CustomBootstrap"/>


<!-- Specify the app entry point class. -->
<entry-point class='com.template.core.client.template' />

<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />

<!-- Form Factors -->
<inherits name="com.template.core.FormFactor" />

<!-- For JSON Ajax call -->
<inherits name="com.google.gwt.http.HTTP" />

<!-- For Logging Framework src: https://developers.google.com/web-toolkit/doc/latest/DevGuideLogging -->
<inherits name="com.google.gwt.logging.Logging" />
<set-property name="gwt.logging.enabled" value="FALSE" />

<define-configuration-property name="gin.ginjector"
    is-multi-valued="false" />
<set-configuration-property name='gin.ginjector'
    value='com.template.core.client.ioc.ClientGinjector' />

<!-- gwt dnd -->
<inherits name='com.allen_sauer.gwt.dnd.gwt-dnd'/>

桌面模块[包含具有桌面特定视图的桌面模块] desktop.gwt.xml 有入口点

desktop.gwt.xml

<?xml version="1.0" encoding="UTF-8"?>

<inherits name='com.template.core.template' />
<entry-point class='com.template.desktop.client.desktoptemplate' />
<source path='client' />

平板电脑模块[包含具有平板电脑特定视图的平板电脑模块] tablet.gwt.xml 有入口点

移动模块[包含具有移动特定视图的移动模块] mobile.gwt.xml 有入口点

台式机、平板电脑和移动设备依赖于核心模块。我也继承了device modules中的core模块,提到了device modules中core的依赖

我可以 运行 这些模块单独使用 google gwt 插件在 eclipse 中完美。但是当我在根项目上执行 maven 安装时,找不到核心模块的入口点并抛出以下异常。

[错误] 找不到类型 'com.template.core.client.template' [INFO] [ERROR] 提示:检查类型名称 'com.template.core.client.template' 是否真的如您所愿 [INFO] [ERROR] 提示:检查您的 classpath 是否包含所有必需的源根目录 [信息] [错误] 'file:/home/software/mmt/template_ui/template_ui_desktop/src/main/java/com/template/desktop/client/desktoptemplate.java' 中的错误 [INFO] [ERROR] 第 20 行:类型 com.template.core.client.ioc.ClientGinjector 没有可用的源代码;您是否忘记继承所需的模块? [INFO] [ERROR] 第 21 行:类型 com.template.core.client.application.main.ServletURL 没有可用的源代码;您是否忘记继承所需的模块? [信息] [错误] 找不到类型 'com.template.desktop.client.desktoptemplate' [INFO] [ERROR] 提示:以前的编译器错误可能导致此类型不可用 [INFO] [ERROR] 提示:检查模块的继承链;它可能没有继承所需的模块,或者模块可能没有正确添加其源路径条目

[INFO] 模板用户界面................................................ ......................... 成功 [ 1.374 秒] [信息] 核心模块................................................ ......................... 成功 [ 46.110 秒] [信息] 桌面模块...................................... ...................................失败 [ 23.713 秒] [信息] 平板电脑模块...................................... ………………………… .......跳过 [信息] 移动模块................................................ ..................................................... ..... 跳过

解决方案

gwt 库应该同时包含 .java 和 .class 文件。所以我们需要打包这两个文件(你也可以有 .css, .png, .html e.t.c., 文件)。您可以使用以下 pom.xml 配置来包含它们。

<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>

    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <includes>
                <include>**/*.ui.xml</include>
                <include>**/*.java</include>
                <include>**/*.gwt.xml</include>
                <include>**/*.html</include>
                <include>**/*.js</include>
                <include>**/*.css</include>
                <include>**/*.gif</include>
                <include>**/*.jpg</include>
                <include>**/*.png</include>
            </includes>
        </resource>
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.ui.xml</include>
                <include>**/*.java</include>
                <include>**/*.gwt.xml</include>
                <include>**/*.html</include>
                <include>**/*.js</include>
                <include>**/*.css</include>
                <include>**/*.gif</include>
                <include>**/*.jpg</include>
                <include>**/*.png</include>
            </includes>
        </resource>
    </resources>

    <testResources>
        <testResource>
            <directory>src/test/resources</directory>
        </testResource>
    </testResources>

我已经在我的内核 pom.xml

中使用了这个配置

gwt 库应该同时包含 .java 和 .class 文件。所以我们需要打包这两个文件(你也可以有 .css, .png, .html e.t.c., 文件)。您可以使用以下 pom.xml 配置来包含它们。

<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>

    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <includes>
                <include>**/*.ui.xml</include>
                <include>**/*.java</include>
                <include>**/*.gwt.xml</include>
                <include>**/*.html</include>
                <include>**/*.js</include>
                <include>**/*.css</include>
                <include>**/*.gif</include>
                <include>**/*.jpg</include>
                <include>**/*.png</include>
            </includes>
        </resource>
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.ui.xml</include>
                <include>**/*.java</include>
                <include>**/*.gwt.xml</include>
                <include>**/*.html</include>
                <include>**/*.js</include>
                <include>**/*.css</include>
                <include>**/*.gif</include>
                <include>**/*.jpg</include>
                <include>**/*.png</include>
            </includes>
        </resource>
    </resources>

    <testResources>
        <testResource>
            <directory>src/test/resources</directory>
        </testResource>
    </testResources>

我在我的内核中使用了这个配置 pom.xml