gwtweb-applicationsproject-structuregoogle-eclipse-plugingoogle-plugin-eclipse

How to Add Static Resources in a GWT Application?


I am trying to add a PNG graphic to a GWT 2.6 application in Eclipse Kepler, using the latest plugins.

I have found numerous StackOverflow questions dealing with this topic, such as this, this, this, this or this. Likewise, there are plenty of resources on the web, such as this, this or this. Ultimately, there are the official docs on the project structure.

They all boil down to putting static resources such as image files into the war or the public folder.

Now, my default project structure created by Eclipse does not seem to contain any folder named public, so I am not sure where that one would be supposed to be located, but I have tried on two machines placing the files in the war folder. Evidently, this does not work, as the custom contents of the war folder is deleted every time I recompile the project.

What am I doing wrong; where are image files or other custom static resources supposed to be placed in my project?


Solution

  • The content of the war folder shouldn't be deleted, except for the specific folder that GWT writes into (war/myapp, assuming you have a rename-to="myapp" in your .gwt.xml). If it does, then there's either a bug in the Google Plugin for Eclipse or a misconfiguration of your Eclipse project.

    Re. the public folder, it should sit just next to your .gwt.xml file (and client, server and/or shared subpackages)

    Whether you'll use one or the other depends on how your module will be used: