153N/AOpenGrok - a wicked fast source browser
153N/A---------------------------------------
153N/AOpenGrok is a fast and usable source code search and cross reference
153N/Aengine, written in Java. It helps you search, cross-reference and navigate
153N/Ayour source tree. It can understand various program file formats and
153N/Aversion control histories like SCCS, RCS, CVS, Subversion and Mercurial.
153N/AOpenGrok is the tool used for the OpenSolaris Source Browser.
153N/A * A servlet container like Tomcat (
5.x or later)
153N/A supporting Servlet 2.4 and JSP 2.0
153N/A * Subversion 1.3.0 or later if SVN support is needed
153N/A * Mercurial 0.9.3 or later if Mercurial support is needed
153N/A * JFlex Ant task (If you want to build OpenGrok)
153N/ASRC_ROOT refers to the directory containing your source tree.
153N/AOpenGrok analyzes the source tree and builds a search index along with
187N/Across-referenced hypertext versions of the source files. These generated
153N/Adata files will be stored in DATA_ROOT directory.
153N/AOpenGrok setup Step.0 - Setting up the Sources.
153N/A----------------------------------------------
153N/ASource base must be available locally for OpenGrok to work efficiently. No
153N/Achanges are required to your source tree. If the code is under source control
153N/Amanagement (SCM) OpenGrok requires the checked out source tree under SRC_ROOT.
153N/AIt is possible for some SCM systems to use a remote repository (Subversion),
153N/Abut this is not recommended due to the performance penalty. CVS must have a
153N/ANote that OpenGrok ignores symbolic links.
153N/A---------------------------------------------------
187N/AUsing command line interface.
187N/A---------------------------------------------------
187N/AStep.1 - Populate DATA_ROOT Directory
187N/A=====================================
Option 1. OpenGrok: There is a sample shell script OpenGrok that is suitable
for using in a cronjob to run regularly. Modify the variables in the script
to point appropriate directories, or as the code suggests factor your local
configuration into a seperate file and simplify future upgrades.
Option 2.
opengrok.jar: You can also directly use the Java application. If
the sources are all located in a directory SRC_ROOT and the data and
hypertext files generated by OpenGrok are to be stored in DATA_ROOT, run
===============================================
To configure the webapp
source.war, look into the parameters defined in
* HEADER: is the fragment of HTML that will be used to display title or
* SRC_ROOT: the absolute path name of the root directory of your source tree
* DATA_ROOT: absolute path of the directory where OpenGrok data
Optional Step.3 - Path Descriptions
-----------------------------------
OpenGrok uses path descriptions in various places (For eg. while showing
directory listings or search results) Example descriptions are in
paths.tsvfile. You can list descriptions for directories one per line tab separated
format path tab description. Refer to example 4 below.
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
edit
web.xml and re-package the jar file.
Then copy the war files to <i>TOMCAT</i>/webapps directory.
* Option 3: Edit the Context container element for the webapp
When invoking OpenGrok to build the index, use -w <webapp> to set the
After the index is built, there's a couple different ways to set the
Context for the servlet container:
<Parameter name="HEADER" value='...' override="false" />
- Create a Context file for the webapp
This file will be named `<webapp>.xml'.
For Tomcat, the file will be located at:
`
TOMCAT/conf/<engine_name>/<hostname>', where <engine_name>
is the Engine that is processing requests and <hostname> is a Host
associated with that Engine. By default, this path is
This file will contain something like the Context described above.
---------------------------------------------------
Using Java DB for history cache
(instead of gzipped xml files)
---------------------------------------------------
You need Java DB
10.x (OpenSolaris: # pkg install SUNWjavadb or SUNWj6dev ,
There are two modes, having Java DB embedded, or running a Java DB server.
Java DB server is default option, I will not describe how to set up embedded
Also the Java DB server has to be running during indexing and for the web application.
Note: To use a bigger database buffer, which may improve performance of both
---------------------------------------------------
---------------------------------------------------
you have to download Findbugs to your machine, and install it where you have
checked out your OpenGrok source code, under the
lib/findbugs directory,
You can now run ant with the findbugs target:
[findbugs] Executing findbugs from ant task
[findbugs] Running FindBugs...
[findbugs] Warnings generated: nnn
If you want to install findbugs some other place than ~/.ant/lib, you can untar the
findbugs, like this (if you have installed fundbugs under the lib directory):
There is also a findbugs-xml ant target that can be used to generate XML files that can
later be parsed,
e.g. by Hudson.
---------------------------------------------------
---------------------------------------------------
If you want to check test coverage on OpenGrok, download Emma from
Now you can instrument your classes, and create a jar file:
If you are using NetBeans, select File - "opengrok" Properties
- libraries - Compile tab. Press the "Add
JAR/Folder" and select
If you are not using netbeans, you have to edit the file
Now you can put the classes into jars and generate distributables:
the run time analysis, use these properties:
directory for easy analyzation.
If you want to test the coverage of the unit tests, you can
ant test (Or Alt+F6 in NetBeans)
Now you should get some output saying that Emma is placing runtime
To generate reports, run ant again:
Note: For full coverage report your system has to provide proper junit test
environment, that would mean:
- you have to use ant 1.7 and above
- at least junit-4.?.jar has to be in ants classpath (
e.g. in ./lib)
- your PATH must contain exuberant ctags binary
- your PATH variable must contain binaries of appropriate SCM SW, so commands
hg, sccs, cvs, git, bzr, svn (svnadmin too) must be available for full report
---------------------------------------------------
---------------------------------------------------
To check that your code follows the standard coding conventions,
You need Version 5.0-beta01 (or newer). Extract the package you have
ln -s checkstyle-5.0-beta01 checkstyle
You also have to create symbolic links to the jar files:
To run checkstyle on the source code, just run ant checkstyle:
Output from the command will be stored in the checkstyle directory.
If you want to install checkstyle some other place than ~/.ant/lib, you can
to tell ant where to find checkstyle, like this (if you have installed
checkstyle under the lib directory):
---------------------------------------------------
---------------------------------------------------
To check the quality of the OpenGrok code you can also use PMD
You also have to make links to the jar files:
To run PMD on the rource code, just run ant pmd:
Outout from the command will be stored in the pmd subdirectory.
If you want to install PMD some other place than ~/.ant/lib, you can
unzip the .zip file to a directory, and use the
pmd.home property
to tell ant where to find PMD, like this (if you have installed
PMD under the lib directory):
---------------------------------------------------
---------------------------------------------------
To see dependencies in the source code, you can use JDepend from
ln -s jdepend-2.9/ jdepend
Output is stored in the jdepend directory:
Martin Englund, Sun Microsystems
Knut Anders Hatlen, Sun Microsystems