Building Spring 3 working with Git
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 :)
mkdir org.springframework.instrument/src/main/resources/META-INF
mkdir org.springframework.instrument.classloading/src/main/resources
mkdir org.springframework.instrument.classloading/src/main/resources/META-INF
mkdir org.springframework.asm/src
mkdir org.springframework.asm/src/main
mkdir org.springframework.asm/src/main/java
mkdir org.springframework.core/src/main/resources
mkdir org.springframework.core/src/main/resources/META-INF
mkdir org.springframework.expression/src/main/resources
mkdir org.springframework.expression/src/main/resources/META-INF
mkdir org.springframework.web/src/main/resources
mkdir org.springframework.web/src/main/resources/META-INF
mkdir org.springframework.orm/src/main/resources
mkdir org.springframework.orm/src/main/resources/META-INF
mkdir org.springframework.context.support/src/main/resources
mkdir org.springframework.context.support/src/main/resources/META-INF
mkdir org.springframework.web.portlet/src/main/resources
mkdir org.springframework.web.portlet/src/main/resources/META-INF
mkdir org.springframework.test/src/main/resources
mkdir org.springframework.test/src/main/resources/META-INF
mkdir org.springframework.integration-tests/src/main
mkdir org.springframework.integration-tests/src/main/java
mkdir org.springframework.integration-tests/src/main/resources
mkdir org.springframework.integration-tests/src/main/resources/META-INF
mkdir org.springframework.instrument/src/test/java
mkdir org.springframework.instrument.classloading/src/test/java
mkdir org.springframework.asm/src/test
mkdir org.springframework.asm/src/test/java
mkdir org.springframework.aspects/src/test/java
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.
About Ken Sipe
Ken has been a practitioner and instructor of RUP since the late 1990s, and an extreme programmer and coach since the middle 2000s. Ken has worked with Fortune 500 companies to small startups in the roles of developer, designer, application architect and enterprise architect. Ken's current focus is on enterprise system automation and continuous delivery systems.
Ken is an international speaker on the subject of software engineering speaking at conferences such as JavaOne, JavaZone, Jax-India, and The Strange Loop. He is a regular speaker with NFJS where he is best known for his architecture and security hacking talks. In 2009, Ken was honored by being awarded the JavaOne Rockstar Award at JavaOne in SF, California and the JavaZone Rockstar Award at JavaZone in Oslo, Norway as the top ranked speaker.
More About Ken »Why Attend the NFJS Tour?
- » Cutting-Edge Technologies
- » Agile Practices
- » Peer Exchange
Current Topics:
- Languages on the JVM: Scala, Groovy, Clojure
- Enterprise Java
- Core Java, Java 7
- Agility
- Testing: Geb, Spock, Easyb
- REST
- NoSQL: MongoDB, Cassandra
- Hadoop
- Spring 3
- Automation Tools: Git, Hudson, Sonar
- HTML5, Ajax, jQuery, Usability
- Mobile Applications - iPhone and Android
- More...
NFJS, the Magazine
December Issue Now AvailableBDD and REST
by Brian SlettenMocks and Stubs in Groovy Tests
by Kenneth KousenAlgorithms for Better Text Search Results
by John GriffinKnowns and Unknowns of Scrum and Agile
by Brian Tarbox

