Sunday, April 3, 2011

Using svn:externals for javadocs on my website

I use subversion to version a simple website. I also use subversion for another project (twilio4j) hosted on Google code. The javadocs for the latter project are kept in the twilio4j repository at Google code.

Lately I have just been manually copying the javadocs directory to my web project, and versioning them there too, then rsyncing my web directory into production like I always have. Today I shortened the number of steps in this task by employing the “svn:externals” property in subversion. It is not a “push one button” build solution, but it is an incremental improvement in my life.

Here’s what I did.

cd /path/to/website
svn propedit svn:externals twilio4j

 

The twilio4j directory already existed and contained materials pertinent to the twilio4j project. However, the twilio4j dir did *not* have a doc subdirectory – we don’t want it to have that subdirectory since we are going to grab that directory from the google code repository.

Next, the propedit command let me edit the properties of my twilio4j directory with my editor. I added one line to the properties, namely:

doc http://twilio4j.googlecode.com/svn/trunk/twilio4j/doc

 

I exited my editor, and performed an svn update, which began fetching external content:

svn update

Fetching external item into 'twilio4j/doc'
A    twilio4j/doc/serialized-form.html
A    twilio4j/doc/stylesheet.css
A    twilio4j/doc/allclasses-frame.html
A    twilio4j/doc/overview-frame.html
A    twilio4j/doc/overview-summary.html
A    twilio4j/doc/package-list
A    twilio4j/doc/overview-tree.html
A    twilio4j/doc/index-files

   ... etc ...

 

I committed my changes to the twilio4j directory (only the properties of that directory were changed).

After committing, an svn status shows that the doc directory is an external source.

svn status
X       twilio4j/doc

 

With this technique I can quickly and easily update my javadocs to match what is in the twilio4j repository and rsync my website into production.