How do people typically create dependencies using Subversion?
Here are some guidelines:
- Avoid copying common code; for example, you don’t want JBoss in every java project
- Be able to easily reference a “pegged” revision of the code. For example, your project may specifically require version 3_2_6 of JBoss
- Be able to track the “bleeding edge” of some dependencies, for example, you may want to always stay current on the spring framework you use
A common strategy for dealing with this situation in Subversion is something called the “externals”. The externals in Subversion could be a link to another subversion repository.
Since all Subversion repositories are identified by URL, it is easy to construct a reference to an external source.
Externals make use of another feature of Subversion, the property.
Properties are simply name/value pairs. An example might make this clearer.
Suppose your development project has the following structure:
And our development project component uses JBoss. We are required to use the latest version of gddwebapps but gddwebapps has specific dependencies on JBoss 3_2_6
And further suppose our development group has setup a repository containing versions of gddwebapps component at this URL:
And the JBoss 3_2_6 is located in another SVN repository
Using the setup below, one would set the built-in subversion property, svn:externals on the /trunk/thirdparty directory.
This property would have this value:
So how would you set this up?
Here is a “How To” example:
cd to …gddwebapptrunkthirdparty directory
svn propset svn:externals “JBoss 3_2_6
Step 3: svn commit
Step 4: svn update
(This will fetch external item into ‘JBoss 3_2_6’)
JBoss_3_2_6 now appears in the ../gddwebapp/trunk folder (workspace) as illustrated in Figure A.
Upon branching i.e. creating a nick_devel branch, external JBoss_3_2_6 appears in the nick_devel workspace as illustrated below in Figures B and C.