When I create a Grails app, it comes with some default files in the web-app directory:
$ find web-app web-app web-app/css web-app/css/errors.css web-app/css/main.css web-app/css/mobile.css web-app/images web-app/images/apple-touch-icon-retina.png web-app/images/apple-touch-icon.png web-app/images/favicon.ico web-app/images/grails_logo.jpg web-app/images/grails_logo.png web-app/images/leftnav_btm.png web-app/images/leftnav_midstretch.png web-app/images/leftnav_top.png web-app/images/skin web-app/images/skin/database_add.png web-app/images/skin/database_delete.png web-app/images/skin/database_edit.png web-app/images/skin/database_save.png web-app/images/skin/database_table.png web-app/images/skin/exclamation.png web-app/images/skin/house.png web-app/images/skin/information.png web-app/images/skin/shadow.jpg web-app/images/skin/sorted_asc.gif web-app/images/skin/sorted_desc.gif web-app/images/spinner.gif web-app/images/springsource.png web-app/js web-app/js/application.js
(META-INF and WEB-INF folders snipped from output)
These files create clutter in my app, and also use the common directory names css, images, and js, that I’m likely to want to use for my own resources.
In the past I’ve manually deleted these, but they return by themselves after running grails upgrade, overwriting my own files in the process.
I can’t see any reason to keep these files around. Is there something I’m missing? If not, how can I get rid of them and make sure they never come back?
According to Burt Beckwith, the correct solution to this is to not use
grails upgrade. Apparently, this is no longer the recommended way to upgrade a Grails application, because it really only does two important things, and that is to bump the version and then clean the app so everything is re-downloaded.Minor Upgrades
From that posting, the recommended process for smaller version changes is:
Another tip Burt provides is:
Major Upgrades
The process for major updates (such as upgrading a 1.x app to a 2.x app), is a little more involved:
Hopefully this will be documented eventually in the official docs, as it makes sense, since the upgrade process is too complicated to effectively be automated.
New Applications
This doesn’t, however, explain how to deal with new applications. Of course, you could simply just delete all Grails-specific files (which I recommend unless you use scaffolding).
Another option is to move all the Grails-specific files into some subdirectory, then manually modify (and/or rename) the
mainlayout, CSS files and resources links to point to these new locations.If you still want to use scaffolding, I recommend copying the
main.gsplayout toscaffolding.gsp, and to create a new resources module just for scaffolding that contains all the default CSS and JS requirements. Then rungrails install-templates, which will provide you with the basic view templates for scaffolding. You can then easily change the layout and add or update the correct resources module.Finally, once you’ve got your base application the way you want, zip it up and save it for later. That’s at least an easy way to only have to do all this once.
As a final note, make sure you use a good, robust version control system, such as git or mercurial. This will make it easy to see what’s been modified if you accidentally run
grails upgrade, and discard or roll back files you’d rather not change. With a decent IDE or GUI, you can usually fix this in a few clicks.