Quick Step-by-Step Spring 3 with Git
- In the directory you would like the spring project execute : "git svn clone --stdlayout https://src.springsource.org/svn/spring-framework"
- change directory to the newly created spring-framework directory
- copy forked script from github.com/kensipe named git-svn-clone-externals to the current directory; make executable and run.
- run "git svn show-ignore > .gitignore"
- run "git gc"
- from the current directory you'll need to create the following directories mkdir org.springframework.instrument/src/main/resources/
- export ANT_OPTS="-XX:MaxPermSize=256m -Xmx1024m"
- change directory to "build-spring-framework" directory
- run "ant"
- wait 20 minutes :)
The first line is standard git-svn to get the repository. If you are new to Git, this will take a few minutes long then a standard svn checkout. It is copying all the changes throughout history to your local .git repo. Fortunately spring 3 is still young from a history standpoint.
svn external - The first issue
The first thing to note is that part of the build process for spring 3 is a project which is added to this svn project as an external, which led me to this post on why svn externals are evil :) evil or not we have to deal with them. This led to a post by Alieniloquent which has some good explanations, followed by what I eventually settled on, a post by Andre Pang, which includes a script he created, which I forked off github. Kudos to Andre!! The script he created (which I can see using again the future), provides a one execution solution to what Alieniloquent blogged. It is beautifully simple. The script provides the following:
- pulls down all the svn externals (spring 3 only has one)
- creates a symlink (mocking what svn would have done)
- adds the symlink and the .git_externals directory to the excludes file
The next step is to get all the svn ignores into the .gitignores file.
version control directory management - the next issue
The explanation behind this issue is that svn allows for and manages empty directories... git does not. git only manages content. There are a number of empty directories which the spring build files expects to be present for the build to succeed. This is based on a standardize build system and a lack of error handling in the build system. If I get some time, I'll send a patch to the springsource guys to fix this. At this time you will have to create all the directories listed.
jvm out of memory issues - the last issue
ant will run out of memory without these changes.... first you will run out of perm space, followed by heap. You may be able to get by with less; I didn't spend much time here. The standard defaults will fail.
Also if you need to update your master branch with git... "git svn rebase" will do the job!
I need to say thanks to those bloggers already noted and to fellow NFJS speaker Matthew McCollough.