Home | History | Annotate | only in /opengrok/trunk
Up to higher level directory
NameDateSize
.hgignore02-Oct-2009304
build.xml21-Oct-200926.2K
CHANGES.txt08-Dec-20084.7K
checkstyle/06-Aug-2009
conf/09-Oct-2009
doc/06-Oct-2009
ext/10-Feb-2009
lib/27-Aug-2009
LICENSE.txt19-Oct-200918.6K
nbproject/02-Nov-2009
NOTICE.txt19-Oct-20091.3K
OpenGrok14-Oct-200920.5K
paths.tsv08-Dec-2008113
platform/08-Dec-2008
README.txt06-Oct-200912.6K
run-quiet.sh08-Dec-2008686
run.bat08-Dec-2008948
run.sh08-Dec-20081.1K
src/08-Dec-2008
test/08-Dec-2008
testdata/08-Dec-2008
tools/28-Aug-2009
web/06-Nov-2009

README.txt

      1 OpenGrok - a wicked fast source browser
      2 ---------------------------------------
      3 
      4 OpenGrok is a fast and usable source code search and cross reference
      5 engine, written in Java. It helps you search, cross-reference and navigate
      6 your source tree. It can understand various program file formats and
      7 version control histories like SCCS, RCS, CVS, Subversion and Mercurial.
      8 
      9 OpenGrok is the tool used for the OpenSolaris Source Browser.
     10 
     11 Requirements
     12 ------------
     13     * Latest Java http://java.sun.com/ (At least 1.5)
     14     * A servlet container like Tomcat (5.x or later)
     15       http://tomcat.apache.org/
     16       supporting Servlet 2.4 and JSP 2.0
     17     * Exuberant Ctags http://ctags.sourceforge.net/
     18     * Subversion 1.3.0 or later if SVN support is needed
     19       http://subversion.tigris.org/
     20     * Mercurial 0.9.3 or later if Mercurial support is needed
     21       http://www.selenic.com/mercurial/wiki/
     22     * JFlex Ant task (If you want to build OpenGrok)
     23       http://www.jflex.org/
     24 
     25 
     26 Usage
     27 -----
     28 SRC_ROOT refers to the directory containing your source tree.
     29 OpenGrok analyzes the source tree and builds a search index along with
     30 cross-referenced hypertext versions of the source files. These generated
     31 data files will be stored in DATA_ROOT directory. 
     32 
     33 OpenGrok setup Step.0 - Setting up the Sources.
     34 ----------------------------------------------
     35 Source base must be available locally for OpenGrok to work efficiently. No
     36 changes are required to your source tree. If the code is under source control
     37 management (SCM) OpenGrok requires the checked out source tree under SRC_ROOT.
     38 It is possible for some SCM systems to use a remote repository (Subversion),
     39 but this is not recommended due to the performance penalty. CVS must have a
     40 local repository.
     41 Note that OpenGrok ignores symbolic links.
     42 
     43 ---------------------------------------------------
     44 Using command line interface.
     45 ---------------------------------------------------
     46 
     47 Step.1 - Populate DATA_ROOT Directory
     48 =====================================
     49 Option 1. OpenGrok: There is a sample shell script OpenGrok that is suitable
     50 for using in a cronjob to run regularly. Modify the variables in the script
     51 to point appropriate directories, or as the code suggests factor your local
     52 configuration into a seperate file and simplify future upgrades.
     53 
     54 Option 2. opengrok.jar: You can also directly use the Java application. If
     55 the sources are all located in a directory SRC_ROOT and the data and
     56 hypertext files generated by OpenGrok are to be stored in DATA_ROOT, run
     57 
     58      $ java -jar opengrok.jar -s SRC_ROOT -d DATA_ROOT
     59 
     60 See opengrok.jar manual below for more details.
     61 
     62 Step.2 - Configure and Deploy source.war Webapp
     63 ===============================================
     64 To configure the webapp source.war, look into the parameters defined in
     65 web.xml of source.war file and change them (see note1) appropriately.
     66 
     67     * HEADER: is the fragment of HTML that will be used to display title or
     68     logo of your project
     69     * SRC_ROOT: the absolute path name of the root directory of your source tree
     70     * DATA_ROOT: absolute path of the directory where OpenGrok data
     71     files are stored
     72 
     73 
     74 Optional Step.3 - Path Descriptions
     75 -----------------------------------
     76 OpenGrok uses path descriptions in various places (For eg. while showing
     77 directory listings or search results) Example descriptions are in paths.tsv
     78 file. You can list descriptions for directories one per line tab separated
     79 format path tab description. Refer to example 4 below.
     80 
     81 Note 1 - Changing webapp parameters: web.xml is the deployment descriptor
     82 for the web application. It is in a Jar file named source.war, you can
     83 change the :
     84 
     85     * Option 1: Unzip the file to TOMCAT/webapps/source/ directory and
     86     change the source/WEB-INF/web.xml and other static html files like
     87     index.html to customize to your project. 
     88     
     89     * Option 2: Extract the web.xml file from source.war file
     90 
     91     	$ unzip source.war WEB-INF/web.xml
     92 	
     93     edit web.xml and re-package the jar file. 
     94 
     95     	$ zip -u source.war WEB-INF/web.xml
     96 
     97     Then copy the war files to <i>TOMCAT</i>/webapps directory.
     98 
     99     * Option 3: Edit the Context container element for the webapp
    100 
    101 	Copy source.war to TOMCAT/webapps
    102 
    103         When invoking OpenGrok to build the index, use -w <webapp> to set the 
    104         context.
    105 
    106         After the index is built, there's a couple different ways to set the
    107         Context for the servlet container:
    108           - Add the Context inside a Host element in TOMCAT/conf/server.xml
    109 
    110 	    <Context path="/<webapp>" docBase="source.war">
    111 	        <Parameter name="DATA_ROOT" value="/path/to/data/root" override="false" />
    112 		<Parameter name="SRC_ROOT" value="/path/to/src/root" override="false" />
    113 		<Parameter name="HEADER" value='...' override="false" />
    114 	    </Context>
    115 
    116           - Create a Context file for the webapp
    117 
    118 	    This file will be named `<webapp>.xml'.
    119 
    120 	    For Tomcat, the file will be located at:
    121 	    `TOMCAT/conf/<engine_name>/<hostname>', where <engine_name>
    122 	    is the Engine that is processing requests and <hostname> is a Host
    123 	    associated with that Engine.  By default, this path is
    124 	    'TOMCAT/conf/Catalina/localhost' or 'TOMCAT/conf/Standalone/localhost'.
    125 
    126 	    This file will contain something like the Context described above.
    127 
    128 ---------------------------------------------------
    129 Using Java DB for history cache
    130 (instead of gzipped xml files)
    131 ---------------------------------------------------
    132 
    133 You need Java DB 10.x (OpenSolaris: # pkg install SUNWjavadb or SUNWj6dev ,
    134 Debian/Ubuntu: # apt-get install sun-java6-javadb).
    135 There are two modes, having Java DB embedded, or running a Java DB server.
    136 Java DB server is default option, I will not describe how to set up embedded
    137 option.
    138 
    139 1) Start the server:
    140 $ mkdir -p $DATA_ROOT/derby
    141 
    142 OpenSolaris:
    143 # svcadm enable javadb
    144 OR
    145 $ java -Dderby.system.home=$DATA_ROOT/derby -jar /opt/SUNWjavadb/lib/derbynet.jar start
    146 OR
    147 $ java -Dderby.system.home=$DATA_ROOT/derby -jar /usr/jdk/instances/jdk1.6.0/db/lib/derbynet.jar start
    148 
    149 Debian:
    150 $ java -Dderby.system.home=$DATA_ROOT/derby -jar /usr/lib/jvm/java-6-sun/db/lib/derbynet.jar start
    151 
    152 
    153 2) You need to have the derbyclient.jar in lib directory of opengrok.jar and in source.war WEB-INF/lib
    154 Copy it over from
    155 OpenSolaris: /opt/SUNWjavadb/lib/derbyclient.jar OR /usr/jdk/instances/jdk1.6.0/db/lib/derbyclient.jar
    156 Debian: /usr/lib/jvm/java-6-sun/db/lib/derbyclient.jar
    157 
    158 3) Use these options with indexer when indexing/generating the configuration:
    159     -D -H
    160 
    161 Also the Java DB server has to be running during indexing and for the web application.
    162 
    163 Note: To use a bigger database buffer, which may improve performance of both
    164 indexing and fetching of history, create a file named derby.properties in
    165 $DATA_ROOT/derby and add this line to it:
    166 derby.storage.pageCacheSize=25000
    167 
    168 ---------------------------------------------------
    169 Using Findbugs
    170 ---------------------------------------------------
    171 If you want to run Findbugs (http://findbugs.sourceforge.net/) on OpenGrok,
    172 you have to download Findbugs to your machine, and install it where you have 
    173 checked out your OpenGrok source code, under the lib/findbugs directory,
    174 like this:
    175 
    176    cd ~/.ant/lib
    177    wget http://..../findbugs-x.y.z.tar.gz
    178    gtar -xf findbugs-x.y.z.tar.gz
    179    mv findbugs-x.y.z findbugs
    180 
    181 You can now run ant with the findbugs target:
    182 
    183   ant findbugs
    184   ...
    185   findbugs:
    186    [findbugs] Executing findbugs from ant task
    187    [findbugs] Running FindBugs...
    188    [findbugs] Warnings generated: nnn
    189    [findbugs] Output saved to findbugs/findbugs.html
    190 
    191 Now, open findbugs/findbugs.html in a web-browser, and start fixing bugs!
    192 
    193 If you want to install findbugs some other place than ~/.ant/lib, you can untar the
    194 .tar.gz file to a directory, and use the findbugs.home property to tell ant where to find
    195 findbugs, like this (if you have installed fundbugs under the lib directory):
    196 
    197   ant findbugs -Dfindbugs.home=lib/findbug
    198 
    199 There is also a findbugs-xml ant target that can be used to generate XML files that can
    200 later be parsed, e.g. by Hudson.
    201 
    202 ---------------------------------------------------
    203 Using Emma
    204 ---------------------------------------------------
    205 If you want to check test coverage on OpenGrok, download Emma from
    206 http://emma.sourceforge.net/. Place emma.jar and emma-ant.jar in the
    207 opengrok/trunk/lib directory, or ~/.ant/lib.
    208 
    209 Now you can instrument your classes, and create a jar file:
    210 
    211    ant emma-instrument
    212 
    213 If you are using NetBeans, select File - "opengrok" Properties 
    214 - libraries - Compile tab. Press the "Add JAR/Folder" and select
    215 lib/emma.jar and lib/emma_ant.jar
    216 
    217 If you are not using netbeans, you have to edit the file 
    218 nbproject/project.properties, and add "lib/emma.jar" and 
    219 "lib/emma_ant.jar" to the javac.classpath inside it.
    220 
    221 Now you can put the classes into jars and generate distributables:
    222 
    223    ant dist
    224 
    225 The classes inside opengrok.jar should now be instrumented.
    226 If you use opengrok.jar for your own set of tests, you need 
    227 emma.jar in the classpath.If you want to specify where to store 
    228 the run time analysis, use these properties:
    229 
    230    emma.coverage.out.file=path/coverage.ec
    231    emma.coverage.out.merge=true
    232 
    233 The coverage.ec file should be placed in the opengrok/trunk/coverage
    234 directory for easy analyzation.
    235 
    236 If you want to test the coverage of the unit tests, you can
    237 run the tests:
    238 
    239    ant test   (Or Alt+F6 in NetBeans)
    240 
    241 Now you should get some output saying that Emma is placing runtime 
    242 coverage data into coverage.ec.
    243 
    244 To generate reports, run ant again:
    245 
    246    ant emma-report
    247 
    248 Look at coverage/coverage.txt, coverage/coverage.xml and 
    249 coverage/coverage.html to see how complete your tests are.
    250 
    251 Note: For full coverage report your system has to provide proper junit test 
    252 environment, that would mean:
    253 - you have to use ant 1.7 and above
    254 - at least junit-4.?.jar has to be in ants classpath (e.g. in ./lib)
    255 - your PATH must contain exuberant ctags binary
    256 - your PATH variable must contain binaries of appropriate SCM SW, so commands
    257 hg, sccs, cvs, git, bzr, svn (svnadmin too) must be available for full report
    258 
    259 ---------------------------------------------------
    260 Using Checkstyle
    261 ---------------------------------------------------
    262 
    263 To check that your code follows the standard coding conventions,
    264 you can use checkstyle from http://checkstyle.sourceforge.net/
    265 
    266 First you must download checkstyle from http://checkstyle.sourceforge.net/ ,
    267 You need Version 5.0-beta01 (or newer). Extract the package you have
    268 downloaded, and create a symbolic link to it from ~/.ant/lib/checkstyle,
    269 e.g. like this:
    270 
    271    cd ~/.ant/lib
    272    unzip ~/Desktop/checkstyle-5.0-beta01.zip
    273    ln -s checkstyle-5.0-beta01 checkstyle
    274 
    275 You also have to create symbolic links to the jar files:
    276 
    277    cd checkstyle
    278    ln -s checkstyle-5.0-beta01.jar checkstyle.jar
    279    ln -s checkstyle-all-5.0-beta01.jar checkstyle-all.jar
    280 
    281 To run checkstyle on the source code, just run ant checkstyle:
    282 
    283    ant checkstyle
    284 
    285 Output from the command will be stored in the checkstyle directory.
    286 
    287 If you want to install checkstyle some other place than ~/.ant/lib, you can
    288 untar the .tar.gz file to a directory, and use the checkstyle.home property
    289 to tell ant where to find checkstyle, like this (if you have installed 
    290 checkstyle under the lib directory):
    291 
    292   ant checkstyle -Dcheckstyle.home=lib/checkstyle
    293 
    294 ---------------------------------------------------
    295 Using PMD
    296 ---------------------------------------------------
    297 
    298 To check the quality of the OpenGrok code you can also use PMD
    299 from http://pmd.sourceforge.net/.
    300 
    301 How to install:
    302 
    303   cd ~/.ant/lib
    304   unzip ~/Desktop/pmd-bin-4.2.2.zip
    305   ln -s pmd-4.2.2/ pmd
    306 
    307 You also have to make links to the jar files:
    308 
    309   cd ~/.ant/lib/pmd/lib
    310   ln -s pmd-4.2.2.jar pmd.jar
    311   ln -s jaxen-1.1.1.jar jaxen.jar
    312 
    313 To run PMD on the rource code, just run ant pmd:
    314 
    315   ant pmd
    316 
    317 Outout from the command will be stored in the pmd subdirectory.
    318 
    319   % ls pmd
    320   pmd_report.html  pmd_report.xml
    321 
    322 If you want to install PMD some other place than ~/.ant/lib, you can
    323 unzip the .zip file to a directory, and use the pmd.home property
    324 to tell ant where to find PMD, like this (if you have installed 
    325 PMD under the lib directory):
    326 
    327   ant pmd -Dpmd.home=lib/pmd-4.2.3
    328 
    329 ---------------------------------------------------
    330 Using JDepend
    331 ---------------------------------------------------
    332 To see dependencies in the source code, you can use JDepend from
    333 http://clarkware.com/software/JDepend.html.
    334 
    335 How to install:
    336 
    337   cd ~/.ant/lib
    338   unzip ~/Desktop/jdepend-2.9.zip
    339   ln -s jdepend-2.9/ jdepend
    340   cd jdepend/lib
    341   ln -s jdepend-2.9.jar jdepend.jar
    342 
    343 How to analyze:
    344 
    345   ant jdepend
    346 
    347 Output is stored in the jdepend directory:
    348 
    349   $ ls jdepend/
    350   report.txt  report.xml
    351 
    352 AUTHORS 
    353 -------
    354 Chandan B.N, Sun Microsystems. https://blogs.sun.com/chandan
    355 Trond Norbye, norbye.org
    356 Knut Pape, eBriefkasten.de
    357 Martin Englund, Sun Microsystems
    358 Knut Anders Hatlen, Sun Microsystems
    359