dkuspawono / google-plugin-for-eclipse

Automatically exported from code.google.com/p/google-plugin-for-eclipse
Eclipse Public License 1.0
0 stars 0 forks source link

m2e + DevMode does not refresh CSS like a normal GWT application #219

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. Clone https://github.com/ArloL/gwt-refresh-demo and import into a properly 
configured Eclipse (m2e, m2e-wtp, GPE)
2. Start Development Mode
3. Open Browser and look at application
4. Edit src/main/webapp/Test.css, e.g. font-size: 10em;
4. Press Refresh and see that your changes are not visible.

What is the expected output? What do you see instead?

You should see the changes you made.

If you create a sample application without Maven you get this behaviour.

What version of the product are you using? On what operating system?

Google Plugin for Eclipse 4.2   3.2.4.v201306061638-rel-r42
Windows Server 2008 R2 Standard

Original issue reported on code.google.com by MailToA...@gmail.com on 25 Jun 2013 at 12:37

GoogleCodeExporter commented 8 years ago
Put your CSS to src/main/resources/your.package.name/public

This way it gets updated. The problem is that the webapp path seems unmanaged 
and the changes in it aren't detected. If this is absolutely necessary, you can 
run devmode in src/main/webapp but I strongly advice you not to. Devmode 
replaces projectname/projectname.nocache.js with its own version and if you 
compile WAR after that it won't work and will complain about the project 
recompiling. I was stuck on it for some time and then found that I should 
delete that JS and recompile the project.

In traditional setup gwt-maven-plugin also says "[WARNING] Your POM 
<build><outputdirectory> does not match your hosted webapp WEB-INF/classes 
folder for GWT Hosted browser to see your classes."

And that seems to be exactly why your changes aren't visible. The bigger 
problem is web.xml not getting updated so you should either compile the project 
(maven copies the entire webapp dir contents to /target then) or copy web.xml 
by hand.

Original comment by radioano...@gmail.com on 30 Jun 2013 at 8:03

GoogleCodeExporter commented 8 years ago
Thanks for your suggestion.

I tried the solution with src/main/resources but could not get it working.

But I did find a solution that works the way I expect it:

I run Dev Mode with -war "target/m2e-wtp/web-resources" instead of 
"target/build.finalName". The combination of m2e-wtp and binding war:exploded 
to compile results in m2e maintaining a fresh copy of "src/main/webapp" in 
"target/m2e-wtp/web-resources". End result is that I am not running Dev Mode 
from my src folder to avoid any GWT compiler errors and I can edit my files and 
hit refresh!

It would be cool if the GPE discovered this by itself but I can imagine that 
this is rather difficult to achieve.

Original comment by MailToA...@gmail.com on 3 Jul 2013 at 7:35

GoogleCodeExporter commented 8 years ago
I double checked my pom and it in fact was not the combination of m2e-wtp and 
binding war:exploded to compile. In fact I have an eclipse lifecycle mapping 
set up to ignore the goal. It was the fact that I am adding src/main/webapp as 
a webResource to the maven-war-plugin like this:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.3</version>
    <configuration>
        <webResources>
            <resource>
                <directory>src/main/webapp</directory>
            </resource>
        </webResources>
    </configuration>
</plugin>

This makes m2e-wtp copy the files to web-resources.

Original comment by MailToA...@gmail.com on 3 Jul 2013 at 9:57

GoogleCodeExporter commented 8 years ago
Glad you figured it out. Anyway, to make the CSS work like I suggested you 
should put it to resources in the "public" directory and add to your 
Projectname.gwt.xml the following line: <stylesheet src="style.css" />

Of course, put your CSS filename there but it's "style.css" most of the time. 
It will be loaded by the startup script (*.nocache.js). You can also put the 
regular <link> tag to your HTML but I don't think it's a good idea. The html 
should be kept as small and common as possible.

Original comment by radioano...@gmail.com on 3 Jul 2013 at 9:57

GoogleCodeExporter commented 8 years ago
It actually is a little more complex than that because I am using 
https://code.google.com/p/wro4j/ to create unique css files that I can send to 
the user with far future expiry headers. Thus the css file name can also change 
during development.

Reading up on how m2e-wtp works with webResources I had an interesting idea: 
How about allowing the GWT Dev Mode to accept overlay folders?

That way one could start the Dev Mode from "src/main/webapp", put the JS 
files+compile output in "target/m2e-wtp/web-resources" and then overlay that 
folder. That way all changes would be immediately visible for all scenarios 
without workarounds.

Original comment by MailToA...@gmail.com on 10 Jul 2013 at 7:33