【问题标题】:GWT DevMode don't reload changes on css filesGWT DevMode 不会重新加载对 css 文件的更改
【发布时间】:2013-08-13 14:11:44
【问题描述】:

我已经使用 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 {

}

如您所见,我的 XOFooterPanelStyle 接口扩展了 CssResource。它用于 XOFooterPanelResource - 它扩展了 ClientBundle - 通过使用带有我的 CSS 文件名称的 @Source 注释。

这是我的 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
        }
    }

如前所述,我在 Eclipse 中使用 tomcat 运行应用程序,因此设置了 -noserver 选项。

【问题讨论】:

    标签: css gwt gradle gwt-dev-mode


    【解决方案1】:

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

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

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

    1) 您可以将 CSS 代码放入您的 ui.xml 文件中,这应该会被 devMode 拾取。
    Tutorial on how to add css to your ui.xml

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

    【讨论】:

    • 作为一种解决方法,使用 maven-resources-plugin 复制资源,src/main/webapp${project.build.directory}/gwt-webapp输出目录>。 maven.apache.org/plugins/maven-resources-plugin/examples/…
    • 我对 webapps 文件夹中的 CSS 文件所做的更改没有被拾取,并且在页面刷新时 gwt 显示 skipped compile because no input files have changed?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-27
    • 1970-01-01
    • 2016-11-10
    相关资源
    最近更新 更多