OpenGrok, make your code searchable

Any organization that develops software has a lot of software around that could be potentially reused. Reusing software is of course a good thing. Serendipity, accidentally coming across useful code is a highly underestimated way for reusing software. To increase the change of software being reused like that is making all source-code searchable. So how do you make all the source-code in your organization searchable, just like open-source but without open-sourcing all your software? A few weeks ago I came across OpenGrok, a web-application that allows you to that: making all your organization’s code searchable. Installation was pretty easy. OpenGrok is a java-webapplication, packaged as a war-file (WebARchive), a standard way of packaging webapplications in Java. There’s a script to install the webapplication in a few popular application servers, such as Apache Tomcat.

I decided to install on Tomcat. Installation was almost a breeze. Only minor challenge was the deploy script wasn’t yet ready for Tomcat 8, but that was fixed easily. After that I indexed some of my source-code I had developed over time, and my I could search my code! Using various query I could find various classes, types that were present in my code. Queries aren’t as advanced as what sites like OpenHub offer, let alone what you can do in Hoogle. Nevertheless, it’s better than having all your code locked up in source-repositories. OpenGrok

Steps to install were as follows. The steps are not extremely detailed, as am writing this a few weeks later. If you need more information, just add a comment below, or contact me:

  • First I downloaded the latest release from OpenGrok at their Github site.
  • OpenGrok needs an applicaton server. I installed the one I knew best, Tomcat using Ubuntu’s package manager: apt-get install tomcat8
  • After that I shortly wondered how to get the opengrok-war deployed into tomcat until I noticed the deployment script in the distribution’s directory could do that for me: ./Opengrok deploy Unfortunately tomcat8 wasn’t supported yet, but as mentioned that was fixed easily. As my patch is already merged you won’t have that problem.
  • The OpenGrok application is now running and I could access the application using http://localhost:8080/source. As expected no code is searchable yet because I did not tell OpenGrok what source-code to index yet.
  • Indexing my code could be done as follows: OpenGrok index ~/workspace/GerbrandsMessyCode
  • I noticed some errors because some of the code I had was still using Subversion and some even in Cvs as source-control. That was fixable by just installing subversion and cvs using Ubuntu’s package manager.
  • Reindexing, and even the history of my ancient code was included.