Most tech books include source code for the included examples, and to get the full benefit of the book, you should download it and work with it as you read the book. Often this code is arranged by chapter and includes packaged web applications in addition to build files and a source tree.
While simply unzipping the example code on your local disk is an option, it is far better to have the code under source control so that you can try new things while retaining the ability to easily revert to a known good state. Just like your production code.
In this article I will explain how to set up a local Subversion repository and import the example code for "Pro JSF and Ajax" from Apress.
Note: This article assumes you have Subversion installed and are familiar with its use. The instructions assume Subversion under Cygwin, and should be the same on Linux or Unix. Subversion is also available for Windows, and the advice here should still apply if you substitute directory paths that make sense.
cd ~/svn_data/repos svnadmin create projsf
Consult [this page] for minimal authorization configuration.
svnserve -d -r ~/svn_data
This will start the svnserve daemon listening on port 3690. Configure your firewall as desired to restrict access. For example, you may want to only allow connections from localhost.
Why svnserve? I use Subversion for Cygwin, but I also use TortoiseSVN?. It turns out that if you create a repository with Cygwin svnadmin and then try to access it using a file:/// url, TortoiseSVN? is unable to deal with it. Using svnserve and a svn:// URL avoids the problem entirely. If this is not your situation, you can skip starting svnserve, and access the repository with file:///path/to/repos/projsf
This is optional, but the convention in a Subversion repository is to have separate directories for tags, branches and trunk.
cd ~/temp svn co svn://localhost/repos/projsf cd projsf svn mkdir tags svn mkdir branches svn mkdir trunk svn commit -m "Added initial repository structure"
Change to the directory above where you unzipped the book source code, and import it into your new repository.
cd ~/temp/ svn import ProJSFandAjax? svn://localhost/repos/projsf/trunk
Note that this will import the content *underneath* the 'ProJSFandAjax?' directory, so you will end up with a repository structure such as:
projsf/trunk/chapter01 projsf/trunk/chapter02 ...
Now that you've imported the source code, you can delete your unzipped copy:
rm -rf ProJSFandAjax?
To make it easier to revert to the initial code, tag the initial checkin:
svn cp svn://localhost/repos/projsf/trunk svn://localhost/repos/projsf/tags/INITIAL_IMPORT -m "Tagged initial import."
cd ~/projects/ svn co svn://localhost/repos/projsf/trunk projsf