README.txt revision 1301
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberOpenGrok - a wicked fast source browser
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber---------------------------------------
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber1. Introduction
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber2. Requirements
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber4. OpenGrok setup
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber5. Optional Command Line Interface Usage
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber6. Change web application properties or name
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber7. OpenGrok systray
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber8. Information for developers
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber10. Contact us
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber1. Introduction
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber---------------
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberOpenGrok is a fast and usable source code search and cross reference
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberengine, written in Java. It helps you search, cross-reference and navigate
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberyour source tree. It can understand various program file formats and
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberversion control histories like SCCS, RCS, CVS, Subversion, Mercurial etc.
7f95145833bb24f54e037f73ecc37444d6635697Dwight EngenOffical page of the project is on:
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber http://hub.opensolaris.org/bin/view/Project+opengrok/
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber2. Requirements
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber---------------
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber * Latest Java (At least 1.6)
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber * A servlet container like Tomcat (6.x or later)
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber supporting Servlet 2.4 and JSP 2.0
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber * Exuberant Ctags
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber * Subversion 1.3.0 or later if SVN support is needed
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber * Mercurial 0.9.3 or later if Mercurial support is needed
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber * If you want to build OpenGrok:
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber - Ant (1.7 and later)
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber - Netbeans (optional, at least 7.1)
9c631ea7c2906f41b23f5c8dcc9f6045078879dbDwight EngenOpenGrok usually runs in servlet container (e.g. Tomcat).
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberSRC_ROOT environment variable refers to the directory containing your source
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Grabertree. OpenGrok analyzes the source tree and builds a search index along with
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Grabercross-referenced hypertext versions of the source files. These generated
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberdata files will be stored in directory referred to with environment variable
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Grabercalled DATA_ROOT.
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberOpenGrok has a concept of Projects - one project is one directory underneath
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberSRC_ROOT directory which usually contains a checkout of a project sources.
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber(this can be branch, version, ...)
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberProjects effectively replace the need to have more web applications, each with
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberopengrok .war file. Instead it leaves you with one indexer and one web
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberapplication serving multiple source code repositories - projects.
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberThen you have a simple update script and simple index refresher script in
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberplace, which simplifies management of more repositories.
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberA nice concept is to have a naming convention for directories underneath
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberSRC_ROOT, thereby creating a good overview of projects (e.g.
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Grabername-version-branch).
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberFor example, the SRC_ROOT directory can contain the following directories:
9c631ea7c2906f41b23f5c8dcc9f6045078879dbDwight Engen openssl-0.9.8-stable
9c631ea7c2906f41b23f5c8dcc9f6045078879dbDwight Engen openssl-1.0.0-stable
9c631ea7c2906f41b23f5c8dcc9f6045078879dbDwight EngenEach of these directories was created with 'cvs checkout' command (with
9c631ea7c2906f41b23f5c8dcc9f6045078879dbDwight Engenappropriate arguments to get given branch) and will be treated by OpenGrok
9c631ea7c2906f41b23f5c8dcc9f6045078879dbDwight Engenas a project.
9c631ea7c2906f41b23f5c8dcc9f6045078879dbDwight Engen4. OpenGrok setup
9c631ea7c2906f41b23f5c8dcc9f6045078879dbDwight Engen-----------------
9c631ea7c2906f41b23f5c8dcc9f6045078879dbDwight EngenTo setup OpenGrok it is needed to prepare the source code, let OpenGrok index
9c631ea7c2906f41b23f5c8dcc9f6045078879dbDwight Engenit and start the web application.
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber4.1 Setting up the sources
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber--------------------------
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberSource base must be available locally for OpenGrok to work efficiently.
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberNo changes are required to your source tree. If the code is under source
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Grabercontrol management (SCM) OpenGrok requires the checked out source tree under
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberBy itself OpenGrok does not perform the setup of the source code repositories
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberor sychronization of the source code with its origin. This is to be done by
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberthe user or automatic scripts.
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberIt is possible for some SCM systems to use a remote repository (Subversion,
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberCVS), but this is not recommended due to the performance penalty. Special
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberoption when running the OpenGrok indexer is needed to enable remote repository
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Grabersupport ("-r on").
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberNote that OpenGrok ignores symbolic links.
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber4.2 Using Opengrok wrapper script to create indexes
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber---------------------------------------------------
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberFor *nix systems there is a shell script called OpenGrok which simplifies most
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberof the tasks. It has been tested on Solaris and Linux distributions.
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber4.2.1 - Deploy the web application
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber----------------------------------
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberFirst please change to opengrok directory where the OpenGrok shell script is
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberstored (can vary on your system).
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberNote that now you might need to change to user which owns the target
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberdirectories for data, e.g. on Solaris you'd do:
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber # pfexec su - webservd
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber $ ./OpenGrok deploy
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberThis command will do some sanity checks and will deploy the source.war in
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberits directory to one of detected web application containers.
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberPlease follow the error message it provides.
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberIf it fails to discover your container, please refer to optional steps on
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberchanging web application properties, which has manual steps on how to do
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberNote that OpenGrok script expects the directory /var/opengrok to be
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberavailable to user running opengrok with all permissions. In root user case
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberit will create all the directories needed, otherwise you have to manually
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Grabercreate the directory and grant all permissions to the user used.
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber4.2.2 - Populate DATA_ROOT Directory
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber------------------------------------
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberDuring this process the indexer will generate OpenGrok XML configuration file
9c631ea7c2906f41b23f5c8dcc9f6045078879dbDwight Engenconfiguration.xml and sends the updated configuration to your web app.
9c631ea7c2906f41b23f5c8dcc9f6045078879dbDwight EngenThe indexing can take a lot of time. After this is done, indexer automatically
9c631ea7c2906f41b23f5c8dcc9f6045078879dbDwight Engenattempts to upload newly generated configuration to the web application.
9c631ea7c2906f41b23f5c8dcc9f6045078879dbDwight EngenMost probably you will not be able to use Opengrok before this is done for the
9c631ea7c2906f41b23f5c8dcc9f6045078879dbDwight EngenPlease change to opengrok directory (can vary on your system)
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberand run, if your SRC_ROOT is prepared under /var/opengrok/src
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber $ ./OpenGrok index
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberotherwise (if SRC_ROOT is in different directory) run:
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber $ ./OpenGrok index <absolute_path_to_your_SRC_ROOT>
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberThe above command attempts to upload the latest index status reflected into
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberconfiguration.xml to a running source web application.
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberOnce above command finishes without errors
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber(e.g. SEVERE: Failed to send configuration to localhost:2424),
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberyou should be able to enjoy your opengrok and search your sources using
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberlatest indexes and setup.
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberCongratulations, you should now be able to point your browser to
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberhttp://<YOUR_WEBAPP_SERVER>:<WEBAPPSRV_PORT>/source to work with your fresh
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberOpenGrok installation! :-)
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberAt this time we'd like to point out some customization to OpenGrok script
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberfor advanced users.
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberA common case would be, that you want the data in some other directory than
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber/var/opengrok. This can be easily achieved by using environment variable
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane GraberOPENGROK_INSTANCE_BASE.
in /tank/source then to get more verbosity run the indexer as:
$ OPENGROK_VERBOSE=true OPENGROK_INSTANCE_BASE=/tank/opengrok \
./OpenGrok index /tank/source
below for our case of having opengrok instance in /tank/opengrok :
$ ln -s /tank/opengrok/etc/configuration.xml \
# svccfg -s opengrok setprop opengrok/maxmemory="2048"
To rebuild the index later (e.g. after source code changed) just run:
Option 2. opengrok.jar: You can also directly use the Java application. If
$ java -jar opengrok.jar -s $SRC_ROOT -d $DATA_ROOT
See opengrok.jar manual below for more details.
4.4.2 - Configure and Deploy source.war Webapp
To configure the webapp source.war, look into the parameters defined in
directory listings or search results) Example descriptions are in paths.tsv
Note 1 - Changing webapp parameters: web.xml is the deployment descriptor
for the web application. It is in a Jar file named source.war, you can
* Option 1: Unzip the file to TOMCAT/webapps/source/ directory and
change the source/WEB-INF/web.xml and other static html files like
index.html to customize to your project.
edit web.xml and re-package the jar file.
- Add the Context inside a Host element in TOMCAT/conf/server.xml
<Context path="/<webapp>" docBase="source.war">
<Parameter name="DATA_ROOT" value="/path/to/data/root" override="false" />
<Parameter name="SRC_ROOT" value="/path/to/src/root" override="false" />
`TOMCAT/conf/<engine_name>/<hostname>', where <engine_name>
# pkg install library/java/javadb
$ mkdir -p $DATA_ROOT/derby
-jar /opt/SUNWjavadb/lib/derbynet.jar start
-jar /usr/lib/jvm/java-6-sun/db/lib/derbynet.jar start
2) Copy derbyclient.jar to the lib directory
The derbyclient.jar is provided with Java DB installation.
The lib directory is the one where opengrok.jar is located.
E.g. for Tomcat it is located in the WEB-INF directory which was created
as a result of deploying the source.war file.
Solaris 11: /opt/SUNWjavadb/lib/derbyclient.jar
3) Use these options with indexer when indexing/generating the configuration:
indexing and fetching of history, create a file named derby.properties in
$DATA_ROOT/derby and add this line to it:
You need to pass location of project file + the query to Search class, e.g.
for fulltext search for project with above generated configuration.xml you'd
/var/opengrok/etc/configuration.xml -f fulltext_search_string
To configure the webapp source.war, look into the parameters defined in
* localhost:<some_port> (e.g. localhost:2424), if you choose some_port
Deploy the modified .war file in glassfish/Sun Java App Server:
it to your source.war webarchive
* Option 2: Copy the source.war file to
GLASSFISH/domains/YOURDOMAIN/autodeploy directory, glassfish will try
An example opengrok-agent.properties file is provided, which can be used when
--config opengrok-agent.properties
$ java -cp ./opengrok.jar \
assuming configuration permits remote connections (i.e. not listening on
If you want to run Findbugs (http://findbugs.sourceforge.net/) on OpenGrok,
checked out your OpenGrok source code, under the lib/findbugs directory,
$ gtar -xf findbugs-x.y.z.tar.gz
$ mv findbugs-x.y.z findbugs
[findbugs] Output saved to findbugs/findbugs.html
Now, open findbugs/findbugs.html in a web-browser, and start fixing bugs !
that can later be parsed, e.g. by Jenkins.
opengrok/trunk/lib directory, or ~/.ant/lib.
- libraries - Compile tab. Press the "Add JAR/Folder" and select
The classes inside opengrok.jar should now be instrumented.
If you use opengrok.jar for your own set of tests, you need
coverage data into coverage.ec.
coverage/coverage.html to see how complete your tests are.
- at least junit-4.?.jar has to be in ants classpath (e.g. in ./lib)
you can use checkstyle from http://checkstyle.sourceforge.net/
First you must download checkstyle from http://checkstyle.sourceforge.net/ ,
downloaded, and create a symbolic link to it from ~/.ant/lib/checkstyle,
e.g. like this:
$ unzip ~/Desktop/checkstyle-5.3.zip
$ unzip ~/Desktop/pmd-bin-4.2.5.zip
$ cd ~/.ant/lib/pmd/lib
unzip the .zip file to a directory, and use the pmd.home property
$ unzip ~/Desktop/jdepend-2.9.zip
$ cd jdepend/lib
The project has been originally conceived in Sun Microsystems by Chandan B.N.
Trond Norbye, norbye.org
Knut Pape, eBriefkasten.de
Knut Anders Hatlen, Oracle. http://blogs.oracle.com/kah/
Lubos Kosco, Oracle. http://blogs.oracle.com/taz/