Setting up {OpenGrok for source code browsing

One of my classes this semester includes a significant programming project, and at the end of the semester I will have to submit the code to my instructor. The project is organized into multiple directories for header files, source files, data file, etc., and is not easily printed off (like my small homework assignments are). I decided that rather than sending the instructor a tarball, I would take the time to set up a web-based source code browser. It’s something I’ve been curious about for a while (ever since I experimented with Pdoc), so I figured it would be worth the investment, even if it’s overkill for this one project.

I did a bit of searching, and {OpenGrok looked like my best bet, so I went ahead and installed the prerequisites and downloaded the {OpenGrok binaries.

  • I recently installed the latest Java JDK on my system, so I was good there
  • I installed Exuberant Ctags with sudo apt-get install exuberant-ctags
  • I installed Apache Tomcat 6 with sudo apt-get install tomcat6
  • I went with the binaries (instead of source) since {OpenGrok is Java-based and can be compiled in a format that is compatible across platforms

After satisfying the dependencies, unpacking and deploying {OpenGrok as a JSP web app was pretty simple.

tar xzf opengrok-0.10.tar.gz
sudo mv opengrok-0.10/ /usr/local/.
cd /usr/local/opengrok-0.10/bin/
sudo ./OpenGrok deploy

At this point, the web app was set up and accessible at http://localhost:8080/source, and all that remained was to index the source code I wanted to share in the browser. I copied a few git repositories into /var/opengrok/src and then ran ./OpenGrok index. It took a few seconds to index my code, and then it was all browsable and searchable through my {OpenGrok instance. All in all, it took less than a half-hour, though if I had to do it again, I could probably do it in 5-10 minutes!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s