GWT DevMode don't reload changes on css files
Asked Answered
D

1

7

i've set up a GWT project using Gradle as build management and everything is fine.
I can deploy my project to my local tomcat in eclipse and the application runs as intended. But if I start the DevMode and change something in my css resources (which are bound as CssResource classes with an @Source annotation), the GWT DevMode doesn't catch it and the css changes are not taken into account. Am I missing something? I would expect the DevMode to detect changes in .css files during development without having to run a gwt compile again.

Here is an example of how i am using the css resources:

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 {

}

As you can see i have my XOFooterPanelStyle interface which extends CssResource. It is used in the XOFooterPanelResource - which extends ClientBundle - by using the @Source annotation with the name of my CSS file.

And here is the part of my gradle build file which is responsible for starting the 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
        }
    }

As mentioned before i'm using tomcat inside eclipse to run the application, so the -noserver option is set.

Deadwood answered 13/8, 2013 at 14:11 Comment(0)
C
0

Unless you are directly changing the css file that tomcat is referencing, you will not see the changes in dev mode. I believe that when you deploy via tomcat in eclipse, your code is not referenced directly from the eclipse project workspace, a copy is moved to the tomcat webapps folder.

I'm not sure what the standard way around this is. I feel like there has to be an option to refresh static resources to the tomcat instance from eclipse, but I haven't looked into it.

Here are two ways i've gotten around the issue when I needed to:

1) You can put CSS code in your ui.xml files, and that should get picked up by devMode.
Tutorial on how to add css to your ui.xml

2) You could also modify the css file in the webapps folder directly, then migrate any changes you made back to the workspace version.

Curson answered 13/8, 2013 at 14:58 Comment(2)
As a workaround use maven-resources-plugin copy-resources, <directory>src/main/webapp</directory><outputDirectory>${project.build.directory}/gwt-webapp</outputDirectory>. maven.apache.org/plugins/maven-resources-plugin/examples/…Tiny
The changes I make to the CSS file in the webapps folder is just not being picked up and on page refresh gwt says skipped compile because no input files have changed?Bravado

© 2022 - 2024 — McMap. All rights reserved.