OpenGrok

From CDOT Wiki
Jump to: navigation, search

Introduction

OpenGrok is a source code searcher similar in idea to MXR. It is very advanced and written in Java. It uses Apache Lucene to build a search database for a source code tree. This tool is perfect for the new mercurial repository as it has built in hg repo parsing. There is only version number searching capability I think: you can't use, for example, FIREFOX_3_1b1_RELEASE in the History box. If there is interest in Mozilla adopting this program, I'd be willing to write support for it. I'd also like to customize the look and feel for the Mozilla web sites. I have a list of things to do in my script.

The Script

Setup

Setting this up is fairly easy if you know your way around a unix shell. You will need the following tools:

  • JDK 1.5+
  • Servlet container - JBoss, Glassfish, Tomcat, Jetty, etc.
  • Exuberant Ctags
  • Mercurial
  • Basic unix programs: sed, zip, unzip, nice, bash

I am assuming you have set up all the required applications installed and configured.

You are going to need to download the opengrok binary release tarball from OpenGrok. Untar it (tar zxf opengrok-0.7.tar.gz) and make note of the directory you put it in. Next you will configure the following variables in my script:

#Mercurial Repository to use
REPO=http://hg.mozilla.org/mozilla-central <-- Change to your HG Repo

#Base directory for contents
BASEDIR=/home/jhford/mozilla <-- This is the base directory for the OpenGrok data files and the HG repo

#This is the name of the data directory for OpenGrok
DATADIR=data-dir <-- This is the folder *name* for opengrok's data

#This is the name of the source directory for OpenGrok
SRCDIR=src-dir <-- This is the folder *name* for opengrok's copy of HG code

#OpenGrok install path - Where is opengrok.jar?
OGDIR="/home/jhford/opengrok/opengrok-0.7" <-- this is where the OpenGrok tarball files ended up. It is likely where you ran "tar zxf opengrok-0.7.tar.gz"

#OpenGrok source.war from opengrok tarball
OGCONTEXT="grokzilla" <-- this variable defines the grokzilla in http://china:8080/grokzilla 
OGWAR="${OGCONTEXT}.war" <-- Likely, you will never need to change this

#Your application server's .war deployment directory
WEBAPPDIR="/home/jhford/tomcat/apache-tomcat-6.0.18/webapps" <-- This is where your app server's war deployment folder is or where you want the resulting war file
<pre>

Then run the script and notice that you have opengrok!  It will likely show up at http://localhost:8080/grokzilla