README.txt revision 911
0N/AOpenGrok - a wicked fast source browser
0N/A---------------------------------------
0N/A
1298N/AOpenGrok is a fast and usable source code search and cross reference
1298N/Aengine, written in Java. It helps you search, cross-reference and navigate
1298N/Ayour source tree. It can understand various program file formats and
1298N/Aversion control histories like SCCS, RCS, CVS, Subversion and Mercurial.
1298N/A
1298N/AOpenGrok is the tool used for the OpenSolaris Source Browser.
1298N/A
1298N/ARequirements
1298N/A------------
1298N/A * Latest Java http://java.sun.com/ (At least 1.5)
1298N/A * A servlet container like Tomcat (5.x or later)
1298N/A http://tomcat.apache.org/
1298N/A supporting Servlet 2.4 and JSP 2.0
1298N/A * Exuberant Ctags http://ctags.sourceforge.net/
1298N/A * Subversion 1.3.0 or later if SVN support is needed
0N/A http://subversion.tigris.org/
0N/A * Mercurial 0.9.3 or later if Mercurial support is needed
0N/A http://www.selenic.com/mercurial/wiki/
1298N/A * JFlex Ant task (If you want to build OpenGrok)
0N/A http://www.jflex.org/
1298N/A
1298N/A
1298N/AUsage
0N/A-----
1298N/ASRC_ROOT refers to the directory containing your source tree.
1298N/AOpenGrok analyzes the source tree and builds a search index along with
1298N/Across-referenced hypertext versions of the source files. These generated
1298N/Adata files will be stored in DATA_ROOT directory.
1298N/A
1073N/AOpenGrok setup Step.0 - Setting up the Sources.
1298N/A----------------------------------------------
0N/ASource base must be available locally for OpenGrok to work efficiently. No
1298N/Achanges are required to your source tree. If the code is under source control
1298N/Amanagement (SCM) OpenGrok requires the checked out source tree under SRC_ROOT.
0N/AIt is possible for some SCM systems to use a remote repository (Subversion),
0N/Abut this is not recommended due to the performance penalty. CVS must have a
115N/Alocal repository.
115N/ANote that OpenGrok ignores symbolic links.
1298N/A
1298N/A---------------------------------------------------
1298N/AUsing command line interface.
1298N/A---------------------------------------------------
1298N/A
1298N/AStep.1 - Populate DATA_ROOT Directory
1298N/A=====================================
0N/AOption 1. OpenGrok: There is a sample shell script OpenGrok that is suitable
1298N/Afor using in a cron job to run regularly. Modify the variables in the script
1298N/Ato point appropriate directories, or as the code suggests factor your local
1298N/Aconfiguration into a separate file and simplify future upgrades.
1298N/A
1298N/AOption 2. opengrok.jar: You can also directly use the Java application. If
1298N/Athe sources are all located in a directory SRC_ROOT and the data and
1298N/Ahypertext files generated by OpenGrok are to be stored in DATA_ROOT, run
0N/A
1298N/A $ java -jar opengrok.jar -s SRC_ROOT -d DATA_ROOT
1298N/A
1298N/ASee opengrok.jar manual below for more details.
1298N/A
1298N/AStep.2 - Configure and Deploy source.war Webapp
1298N/A===============================================
1298N/ATo configure the webapp source.war, look into the parameters defined in
1298N/Aweb.xml of source.war file and change them (see note1) appropriately.
1298N/A
1298N/A * HEADER: is the fragment of HTML that will be used to display title or
1298N/A logo of your project
1298N/A * SRC_ROOT: the absolute path name of the root directory of your source tree
1298N/A * DATA_ROOT: absolute path of the directory where OpenGrok data
1298N/A files are stored
1298N/A
1298N/A
1298N/AOptional Step.3 - Path Descriptions
1298N/A-----------------------------------
1298N/AOpenGrok uses path descriptions in various places (For eg. while showing
1298N/Adirectory listings or search results) Example descriptions are in paths.tsv
1298N/Afile. You can list descriptions for directories one per line tab separated
0N/Aformat path tab description. Refer to example 4 below.
1298N/A
1298N/ANote 1 - Changing webapp parameters: web.xml is the deployment descriptor
1298N/Afor the web application. It is in a Jar file named source.war, you can
1298N/Achange the :
1298N/A
1298N/A * Option 1: Unzip the file to TOMCAT/webapps/source/ directory and
1298N/A change the source/WEB-INF/web.xml and other static html files like
1298N/A index.html to customize to your project.
1298N/A
1298N/A * Option 2: Extract the web.xml file from source.war file
1298N/A
1298N/A $ unzip source.war WEB-INF/web.xml
1298N/A
1298N/A edit web.xml and re-package the jar file.
1298N/A
1298N/A $ zip -u source.war WEB-INF/web.xml
1298N/A
1298N/A Then copy the war files to <i>TOMCAT</i>/webapps directory.
1298N/A
1298N/A * Option 3: Edit the Context container element for the webapp
1298N/A
1298N/A Copy source.war to TOMCAT/webapps
1298N/A
1298N/A When invoking OpenGrok to build the index, use -w <webapp> to set the
1298N/A context.
1298N/A
975N/A After the index is built, there's a couple different ways to set the
975N/A Context for the servlet container:
1298N/A - Add the Context inside a Host element in TOMCAT/conf/server.xml
1298N/A
1298N/A <Context path="/<webapp>" docBase="source.war">
0N/A <Parameter name="DATA_ROOT" value="/path/to/data/root" override="false" />
0N/A <Parameter name="SRC_ROOT" value="/path/to/src/root" override="false" />
1298N/A <Parameter name="HEADER" value='...' override="false" />
975N/A </Context>
975N/A
1298N/A - Create a Context file for the webapp
1298N/A
1298N/A This file will be named `<webapp>.xml'.
1298N/A
1298N/A For Tomcat, the file will be located at:
975N/A `TOMCAT/conf/<engine_name>/<hostname>', where <engine_name>
1298N/A is the Engine that is processing requests and <hostname> is a Host
1298N/A associated with that Engine. By default, this path is
1298N/A 'TOMCAT/conf/Catalina/localhost' or 'TOMCAT/conf/Standalone/localhost'.
979N/A
1298N/A This file will contain something like the Context described above.
975N/A
1298N/A---------------------------------------------------
1298N/AUsing Java DB for history cache
975N/A(instead of gzipped xml files)
975N/A---------------------------------------------------
975N/A
1298N/AYou need Java DB 10.5.3 or later
975N/A(OpenSolaris: # pkg install SUNWjavadb or SUNWj6dev ,
975N/ADebian/Ubuntu: # apt-get install sun-java6-javadb).
975N/AThere are two modes, having Java DB embedded, or running a Java DB server.
975N/AJava DB server is default option, I will not describe how to set up embedded
975N/Aoption.
975N/A
975N/A1) Start the server:
975N/A$ mkdir -p $DATA_ROOT/derby
975N/A
975N/AOpenSolaris:
975N/A# svcadm enable javadb
975N/AOR
975N/A$ java -Dderby.system.home=$DATA_ROOT/derby -jar /opt/SUNWjavadb/lib/derbynet.jar start
975N/AOR
1298N/A$ java -Dderby.system.home=$DATA_ROOT/derby -jar /usr/jdk/instances/jdk1.6.0/db/lib/derbynet.jar start
1298N/A
975N/ADebian:
1298N/A$ java -Dderby.system.home=$DATA_ROOT/derby -jar /usr/lib/jvm/java-6-sun/db/lib/derbynet.jar start
1298N/A
1298N/A
1298N/A2) You need to have the derbyclient.jar in lib directory of opengrok.jar and in source.war WEB-INF/lib
1298N/ACopy it over from
1298N/AOpenSolaris: /opt/SUNWjavadb/lib/derbyclient.jar OR /usr/jdk/instances/jdk1.6.0/db/lib/derbyclient.jar
1298N/ADebian: /usr/lib/jvm/java-6-sun/db/lib/derbyclient.jar
975N/A
975N/A3) Use these options with indexer when indexing/generating the configuration:
975N/A -D -H
1298N/A
975N/AAlso the Java DB server has to be running during indexing and for the web application.
975N/A
975N/ANote: To use a bigger database buffer, which may improve performance of both
1298N/Aindexing and fetching of history, create a file named derby.properties in
975N/A$DATA_ROOT/derby and add this line to it:
975N/Aderby.storage.pageCacheSize=25000
975N/A
1298N/A---------------------------------------------------
975N/AUsing Findbugs
975N/A---------------------------------------------------
975N/AIf you want to run Findbugs (http://findbugs.sourceforge.net/) on OpenGrok,
975N/Ayou have to download Findbugs to your machine, and install it where you have
975N/Achecked out your OpenGrok source code, under the lib/findbugs directory,
975N/Alike this:
975N/A
975N/A cd ~/.ant/lib
975N/A wget http://..../findbugs-x.y.z.tar.gz
975N/A gtar -xf findbugs-x.y.z.tar.gz
1298N/A mv findbugs-x.y.z findbugs
975N/A
975N/AYou can now run ant with the findbugs target:
975N/A
975N/A ant findbugs
1298N/A ...
1298N/A findbugs:
975N/A [findbugs] Executing findbugs from ant task
1298N/A [findbugs] Running FindBugs...
1298N/A [findbugs] Warnings generated: nnn
1298N/A [findbugs] Output saved to findbugs/findbugs.html
1298N/A
1298N/ANow, open findbugs/findbugs.html in a web-browser, and start fixing bugs!
975N/A
975N/AIf you want to install findbugs some other place than ~/.ant/lib, you can untar the
975N/A.tar.gz file to a directory, and use the findbugs.home property to tell ant where to find
975N/Afindbugs, like this (if you have installed fundbugs under the lib directory):
975N/A
1298N/A ant findbugs -Dfindbugs.home=lib/findbug
1298N/A
975N/AThere is also a findbugs-xml ant target that can be used to generate XML files that can
1298N/Alater be parsed, e.g. by Hudson.
975N/A
975N/A---------------------------------------------------
975N/AUsing Emma
975N/A---------------------------------------------------
975N/AIf you want to check test coverage on OpenGrok, download Emma from
975N/Ahttp://emma.sourceforge.net/. Place emma.jar and emma-ant.jar in the
1298N/Aopengrok/trunk/lib directory, or ~/.ant/lib.
1298N/A
975N/ANow you can instrument your classes, and create a jar file:
975N/A
975N/A ant emma-instrument
1298N/A
1298N/AIf you are using NetBeans, select File - "opengrok" Properties
1298N/A- libraries - Compile tab. Press the "Add JAR/Folder" and select
975N/Alib/emma.jar and lib/emma_ant.jar
1298N/A
975N/AIf you are not using netbeans, you have to edit the file
975N/Anbproject/project.properties, and add "lib/emma.jar" and
1298N/A"lib/emma_ant.jar" to the javac.classpath inside it.
1298N/A
1298N/ANow you can put the classes into jars and generate distributables:
1298N/A
1298N/A ant dist
975N/A
984N/AThe classes inside opengrok.jar should now be instrumented.
984N/AIf you use opengrok.jar for your own set of tests, you need
984N/Aemma.jar in the classpath.If you want to specify where to store
1298N/Athe run time analysis, use these properties:
1298N/A
984N/A emma.coverage.out.file=path/coverage.ec
1298N/A emma.coverage.out.merge=true
1298N/A
1298N/AThe coverage.ec file should be placed in the opengrok/trunk/coverage
975N/Adirectory for easy analyzation.
984N/A
984N/AIf you want to test the coverage of the unit tests, you can
984N/Arun the tests:
975N/A
1298N/A ant test (Or Alt+F6 in NetBeans)
1298N/A
0N/ANow you should get some output saying that Emma is placing runtime
1298N/Acoverage data into coverage.ec.
1298N/A
1298N/ATo generate reports, run ant again:
1298N/A
1298N/A ant emma-report
299N/A
911N/ALook at coverage/coverage.txt, coverage/coverage.xml and
299N/Acoverage/coverage.html to see how complete your tests are.
911N/A
0N/ANote: For full coverage report your system has to provide proper junit test
0N/Aenvironment, that would mean:
0N/A- you have to use ant 1.7 and above
0N/A- at least junit-4.?.jar has to be in ants classpath (e.g. in ./lib)
0N/A- your PATH must contain exuberant ctags binary
1298N/A- your PATH variable must contain binaries of appropriate SCM SW, so commands
0N/Ahg, sccs, cvs, git, bzr, svn (svnadmin too) must be available for full report
0N/A
0N/A---------------------------------------------------
1298N/AUsing Checkstyle
1298N/A---------------------------------------------------
1298N/A
0N/ATo check that your code follows the standard coding conventions,
0N/Ayou can use checkstyle from http://checkstyle.sourceforge.net/
0N/A
0N/AFirst you must download checkstyle from http://checkstyle.sourceforge.net/ ,
0N/AYou need Version 5.0-beta01 (or newer). Extract the package you have
1298N/Adownloaded, and create a symbolic link to it from ~/.ant/lib/checkstyle,
0N/Ae.g. like this:
0N/A
1290N/A cd ~/.ant/lib
1290N/A unzip ~/Desktop/checkstyle-5.0-beta01.zip
1290N/A ln -s checkstyle-5.0-beta01 checkstyle
0N/A
1298N/AYou also have to create symbolic links to the jar files:
1298N/A
1298N/A cd checkstyle
0N/A ln -s checkstyle-5.0-beta01.jar checkstyle.jar
0N/A ln -s checkstyle-all-5.0-beta01.jar checkstyle-all.jar
0N/A
0N/ATo run checkstyle on the source code, just run ant checkstyle:
0N/A
115N/A ant checkstyle
0N/A
116N/AOutput from the command will be stored in the checkstyle directory.
0N/A
0N/AIf you want to install checkstyle some other place than ~/.ant/lib, you can
979N/Auntar the .tar.gz file to a directory, and use the checkstyle.home property
979N/Ato tell ant where to find checkstyle, like this (if you have installed
0N/Acheckstyle under the lib directory):
0N/A
0N/A ant checkstyle -Dcheckstyle.home=lib/checkstyle
979N/A
979N/A---------------------------------------------------
979N/AUsing PMD
0N/A---------------------------------------------------
979N/A
0N/ATo check the quality of the OpenGrok code you can also use PMD
979N/Afrom http://pmd.sourceforge.net/.
0N/A
116N/AHow to install:
116N/A
979N/A cd ~/.ant/lib
116N/A unzip ~/Desktop/pmd-bin-4.2.2.zip
979N/A ln -s pmd-4.2.2/ pmd
979N/A
116N/AYou also have to make links to the jar files:
979N/A
979N/A cd ~/.ant/lib/pmd/lib
979N/A ln -s pmd-4.2.2.jar pmd.jar
116N/A ln -s jaxen-1.1.1.jar jaxen.jar
979N/A
979N/ATo run PMD on the rource code, just run ant pmd:
979N/A
979N/A ant pmd
979N/A
116N/AOutout from the command will be stored in the pmd subdirectory.
979N/A
116N/A % ls pmd
979N/A pmd_report.html pmd_report.xml
116N/A
979N/AIf you want to install PMD some other place than ~/.ant/lib, you can
979N/Aunzip the .zip file to a directory, and use the pmd.home property
979N/Ato tell ant where to find PMD, like this (if you have installed
979N/APMD under the lib directory):
979N/A
116N/A ant pmd -Dpmd.home=lib/pmd-4.2.3
979N/A
975N/A---------------------------------------------------
1298N/AUsing JDepend
1298N/A---------------------------------------------------
1298N/ATo see dependencies in the source code, you can use JDepend from
1298N/Ahttp://clarkware.com/software/JDepend.html.
1298N/A
1298N/AHow to install:
1298N/A
863N/A cd ~/.ant/lib
1298N/A unzip ~/Desktop/jdepend-2.9.zip
1298N/A ln -s jdepend-2.9/ jdepend
1298N/A cd jdepend/lib
1298N/A ln -s jdepend-2.9.jar jdepend.jar
1298N/A
1298N/AHow to analyze:
1298N/A
1298N/A ant jdepend
1298N/A
1298N/AOutput is stored in the jdepend directory:
863N/A
1086N/A $ ls jdepend/
863N/A report.txt report.xml
863N/A
863N/AAUTHORS
1298N/A-------
1298N/AChandan B.N, Sun Microsystems. https://blogs.sun.com/chandan
1298N/ATrond Norbye, norbye.org
1298N/AKnut Pape, eBriefkasten.de
863N/AMartin Englund, Sun Microsystems
1298N/AKnut Anders Hatlen, Sun Microsystems
1298N/A