Last updated by 5 years ago

Page: Checking Projects into SVN, Version:3

Checking Projects into SVN

Author: Marc Palmer

The information in here should be easily adapted to CVS. Replace the svn propset svn:ignore commands to set the same text in .cvsignore files in the directories specified in the commands.
Up to and including Grails 0.4.x there are files that are generated or copied by Grails within your project tree. This can be problematic as it is unclear what is to go into SVN and what isn't. In addition, you will not usually want your compiled .class files going into version control, nor duplicates of your libs etc.
This is correct at the time of writing (Grails 0.4.x) but makes the following assumptions:
  • You do not want ./plugins/core (Core Grails plugins) under SVN
  • You do not want anything under ./web-app/WEB-INF/ under SVN. You should not usually need to put files in here. Files from ./conf are copied to WEB-INF/classes so they are on the classpath, if you need to supply anything.
Why is this such a hassle? Well SVN prevents files or directories being considered for version control by checking an "ignores" list that is set via an SVN property. This property is set on specific directories within your SVN working copy. Therein lies the problem - until you have a working copy you cannot tell it to ignore files.

Creating a new project and putting it into SVN

This approach is for use when starting a new Grails project - i.e. it does not yet exist on your disk at all, nor in SVN. It will talk you through your first check in, including the relevant svn:ignore properties, and avoids any checkin of these ignored files that may or may not exist locally.

With SVN installed, create your project. We will use "MyProject" as the name for the purposes of demonstration:

grails create-app MyProject
cd <projname>
Now you must create an empty SVN directory under your SVN repository using whatever appropriate tools you have. This directory should be called the same as MyProject but it doesn't have to be. We will call this SVN repository directory path "emptysvndir" for this example. Next you do:
svn checkout <svn-server-url>/emptysvndir/ .
svn add *
svn propset svn:ignore "WEB-INF" web-app/
svn propset svn:ignore "core" plugins/ //as of grails v1.0.3 there is no plugins/core directory
svn rm --force web-app/WEB-INF
svn rm --force plugins/core
svn commit -m "First commit"
That should have your project committed, and changes to ./plugins/core and ./web-app/WEB-INF/ should be ignored by SVN.

You will not need to check out this project as we have used the "in place import" technique.


Fixing an existing project that is already in SVN

This approach is for use when you have optimistically imported your entire project into SVN already and have started getting errors or are being annoyed by the warning messages relating to locally changed files.

We will use "MyProject" as the name for the purposes of demonstration:

cd MyProject
svn propset svn:ignore "WEB-INF" web-app/
svn propset svn:ignore "core" plugins/
svn rm web-app/WEB-INF
svn rm plugins/core
svn commit -m "Fixing SVN"
That should have your project committed, and changes to ./plugins/core and ./web-app/WEB-INF/ should be ignored by SVN.

Checking out from SVN

To checkout this project fresh locally or on another machine you will need to checkout as usual but then run:

grails upgrade
The grails upgrade command re-instate some files that we are not checking in. This applies mainly to the files under WEB-INF/ dir: including applicationContext.xml, tld/* , sitemesh.xml , web.template.xml etc.