GWT DevMode不会重新加载css文件的更改

Koi*_*umi 5 css gwt gradle gwt-dev-mode

我使用Gradle作为构建管理建立了一个GWT项目,一切都很好.
我可以在eclipse中将我的项目部署到我的本地tomcat,并且应用程序按预期运行.但是,如果我启动DevMode并在我的css资源中更改某些内容(使用@Source注释绑定为CssResource类),GWT DevMode不会捕获它,并且不会考虑css更改.我错过了什么吗?我希望DevMode能够在开发期间检测.css文件中的更改,而无需再次运行gwt编译.

以下是我如何使用css资源的示例:

public interface XOFooterPanelResource extends FooterPanelResource, ClientBundle {
    @Override
    @Source("XOFooterPanel.css")
    XOFooterPanelStyle style();

    @Override
    @ImageOptions(repeatStyle = RepeatStyle.Horizontal)
    ImageResource footerPanelBackground();

    @Override
    @ImageOptions(repeatStyle = RepeatStyle.Horizontal)
    ImageResource footerPanelBackgroundEndUser();

    @Override
    @Source("footerDelimiter.jpg")
    ImageResource footerDelimiter();
}

public interface XOFooterPanelStyle extends FooterPanelStyle, CssResource {

}
Run Code Online (Sandbox Code Playgroud)

正如你所看到的,我有一个扩展CssResource的XOFooterPanelStyle接口.它在XOFooterPanelResource中使用 - 它扩展了ClientBundle - 使用@Source注释和我的CSS文件的名称.

这是我的gradle构建文件的一部分,它负责启动DevMode:

javaexec {
        main = 'com.google.gwt.dev.DevMode'

        jvmArgs = ['-Xmx2048M', '-XX:MaxPermSize=1024M']

        classpath {
            [
                sourceSets.main.java.srcDirs,
                // Java source
                sourceSets.main.output.resourcesDir,
                // Generated resources
                sourceSets.main.output.classesDir,
                // Generated classes
                sourceSets.main.compileClasspath       // Deps
            ]
        }

        args = [
                '-startupUrl', 
                'myapp/index.html', 
                '-noserver',
                '-war',
                'build/devmode',
                '-gen',
                'gen'
            ]
        ext.gwtModules.each {
            args += it
        }
    }
Run Code Online (Sandbox Code Playgroud)

如前所述,我在eclipse中使用tomcat来运行应用程序,因此-noserver选项已设置.

agl*_*man 0

除非您直接更改 tomcat 引用的 css 文件,否则您将不会在开发模式下看到更改。我相信,当您在 eclipse 中通过 tomcat 进行部署时,您的代码不会直接从 eclipse 项目工作区引用,而是将副本移动到 tomcat webapps 文件夹中。

我不确定解决这个问题的标准方法是什么。我觉得必须有一个选项可以从 eclipse 将静态资源刷新到 tomcat 实例,但我还没有研究过。

当我需要时,我可以通过以下两种方法解决这个问题:

1) 您可以将 CSS 代码放入 ui.xml 文件中,devMode 应该会拾取该代码。
有关如何将 css 添加到 ui.xml 的教程

2)您还可以直接修改webapps文件夹中的css文件,然后将所做的任何更改迁移回工作区版本。