Subversion provides an easy way to add references to other projects. These projects might provide frameworks or other resources that your project needs. Rather than copying these resources into your own repository and trying to manage revisions yourself, Subversion allows you to specify a link to the external project. This is done with the
svn:externals directory property.
To add an external project to your own, first decide where you would like it to live. One option is to keep a directory outside of the
trunk directory called
third-party (the name is up to you) and then add tagged versions of the external code to the directory as needed. Another option is to place the externals directory inside the
trunk and then when you branch or the trunk, the correct version of the external project will travel to the
branches directory. In any event, you first have to decide where you want the external project to reside within your own.
Next, use the
svn propedit svn:externals <dir_name> on a directory that is versioned. The format of the property is
destination_dir [-rversion] source_url. Since
svn:externals can be a multiline property, it is best to use the
svn propedit command.
Then, do an
svn update and your done!
I use two (so far) external projects in the Sidelight Project. I use the Xcode configuration files from the Google Toolbox for Mac and the Google Testing Framework called googletest for unit testing the C++ frameworks. I put these external frameworks in a directory called "externals" just under the "trunk" directory in the repository. An
svn propget svn:externals on
computer:sidelight username$ svn propget svn:externals trunk externals/src/google-toolbox-for-mac/1.5/XcodeConfig http://google-toolbox-for-mac.googlecode.com/svn/tags/google-toolbox-for-mac-1.5.1/XcodeConfig externals/src/googletest/1.0 http://googletest.googlecode.com/svn/tags/release-1.0.1
In this case, I have put tagged versions of the external projects into
externals since I want them to remain stable until I update them. Alternatively you could check out a particular version of the project's trunk by specifying the version in the property.
Adding links to external projects to your own project is a great alternative to copying the resources directly and trying to keep synchronized with the external project. Additionally, other developers can share the same properties without a need to configure their own machines. Subversion makes this easy with the