GWT Maven多模块

曼妮·特雅(Manne Teja)

我已经创建了具有以下结构的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

台式机,平板电脑和移动设备取决于核心模块。我还继承了设备模块中的核心模块,并提到了设备模块中核心的依赖性

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

[错误]找不到类型'com.template.core.client.template'[INFO] [错误]提示:检查类型名称'com.template.core.client.template'的含义与您的意思相同[INFO] [错误]提示:检查类路径是否包含所有必需的源根。[信息] [错误]'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类型没有源代码;您忘了继承必需的模块吗?[INFO] [ERROR]找不到类型'com.template.desktop.client.desktoptemplate'[INFO] [ERROR]提示:以前的编译器错误可能使这种类型不可用[INFO] [ERROR]提示:检查模块的继承链;否则,可能会发生错误。它可能未继承所需的模块,或者模块未正确添加其源路径条目

[INFO]模板用户界面........................................... .................................成功[1.374 s] [INFO]核心模块................ ................................................... ...................成功[46.110 s] [INFO]桌面模块.................. ................................................... ...... FAILURE [23.713 s] [INFO]数位板模块.......................... .......................................................... ....................... SKIPPED [INFO]移动模块..................... ................................................... .............................跳过

解决方案

一个gwt库应该同时具有.java和.class文件。这样我们就需要打包两个文件(也可以包含.css,.png,.html等文件)。您可以使用下面的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中使用了此配置

曼妮·特雅(Manne Teja)

一个gwt库应该同时具有.java和.class文件。这样我们就需要打包两个文件(也可以包含.css,.png,.html等文件)。您可以使用下面的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中使用了此配置

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章