OpenGrok Setup for source code browsing



Daily routine for any developer is to search the code base for occurrence of a variable, function call and rest. Some times we remember the function name but forget to file name of the function.

Having tools like eclipse would solve this problem, but what if you have to look  for code for multiple techonlogies like c++, java and different release versions.


And if non developer wants to check a snippet of code, it would be next to impossible task..

Open Grok solves all  this problem.

OpenGrok is a source code search and cross reference engine. It helps programmers to search, cross-reference and navigate source code trees.


 Following are list of steps for installing and using opengrok..

 Required components:
1. Open Grok Binary
2. Ctags
3. Apache Tomcat


1. Copy Open Grok to a specific folder. .extract opengrok (say C:\opengrok)
2. Copy Ctags to a specific folder. (say C:\ctags)
3. Generatae Configiration.xml file using above command.

C:\opengrok\lib>java -jar opengrok.jar -W C:\opengrok\configuration.xml -c C:\ctags\ctags.exe  -P -S -v -s  C:\CodeSource -d C:\opengrok\grokdata

4. this would generate a configuration.xml file


Confiugration.xml file :


<?xml version="1.0" encoding="UTF-8"?>
<java version="1.7.0_09" class="java.beans.XMLDecoder">
 <object class="org.opensolaris.opengrok.configuration.Configuration">
  <void property="cmds">
   <object class="java.util.Collections" method="unmodifiableMap">
    <object class="java.util.HashMap">
     <void method="put">
      <string>org.opensolaris.opengrok.history.PerforceRepository</string>
      <string>p4</string>
     </void>
     <void method="put">
      <string>org.opensolaris.opengrok.history.ClearCaseRepository</string>
      <string>cleartool</string>
     </void>
    </object>
   </object>
  </void>
  <void property="ctags">
   <string>C:\ctags\ctags.exe</string>
  </void>
  <void property="dataRoot">
   <string>C:\opengrok\grokdata</string>
  </void>
  <void property="sourceRoot">
   <string>C:\CodeSource</string>
  </void>
  <void property="verbose">
   <boolean>true</boolean>
  </void>
 </object>
</java>


5.   extract. source.war file present in C:\opengrok\lib
edit web.xml file:


WEB
  <display-name>OpenGrok</display-name>
  <description>A wicked fast source browser</description>
  <context-param>
    <param-name>CONFIGURATION</param-name>
    <param-value>C:\\opengrok\\configuration.xml</param-value>
    <description>Full path to the configuration file where OpenGrok can read it's configuration</description>
  </context-param>



6. create war file again and deploy it in tomcat foler.

No comments:

Post a Comment