Setup Opengrok and tomcat on Ubuntu

To install the tomcat 7 you need to run:

  $ sudo apt-get install default-jdk tomcat7
  $ cd /usr/share/tomcat7/bin/
  $ ./catalina.sh

Then edit your ~/.bashrc and include using the directory pointed by CATALINA_BASE include the following var:

  export CATALINA_HOME=/usr/share/tomcat7/
Run the tomcat and check if it is working:

$ . /etc/init.d/tomcat7
Open web address: http://localhost:8080/
Result on your browser:

Install OpenGrok
First, you need to install the exuberant C tags

$ sudo apt-get install exuberant-ctags openjdk-7-jdk
Download Opengrok binary from the bellow link:
After download and extract it (E.g. I put it under /home/darrenl/tools/opengrok-0.12.5):

$ tar -zxvf opengrok-
Second, create a folder and soft link to your code in order to generate index
  • $ cd ~ ; mkdir local_src ; cd local_src/ ; mkdir data src ; cd src/ $ ln -s ~/code/base/mir/ mir
My case (Create soft links from ~/development/android_core, ~/development/caffe, etc..):
  • $ ln -s ~/development/android_core ~/local_src/src/ $ ln -s ~/development/caffe ~/local_src/src/

Third, edit your ~/.bashrc again and paste the bellow text to add the path of OpenGrok binary to path environment var.
  • export OPENGROK_INSTANCE_BASE=~/local_src
  • export PATH=$PATH:~/tools/opengrok-

In the end, using OpenGrok to deploying, index the source in ~/local/src/
  • $ source ~/.bashrc $ cd ~/tools/opengrok-; sudo ./OpenGrok deploy $ OpenGrok index You can ingore some files by setting IGNORE_PATTERNS $ IGNORE_PATTERNS="-i *.git -i *.so -i *.apk -i d:.git" OpenGrok index
Run it on browser:

Besides, co-workers can see the code accessing the following addresses: <IP>:<PORT>/source or <hostname>:<PORT>/source

Update index

Whenever you create a link or source files in ~/local_src, you need to call $ OpenGrok index to update. And then refresh your browser screen again (F5).

Run $OpenGrok index on start up:

    $ cd ~/.config/autostart; vi opengrok.desktop
Paste the bellow content to opengrok.desktop and save it. Then, the computer will execute $ OpenGrok index when booting up.

[Desktop Entry]
GenericName=A fast and usable source code search and cross reference engine
Comment=A fast and usable source code search and cross reference engine
Exec=OpenGrok index

Note: If your OS is based on Linux, I strongly recommend that you should use Opengrok + Docker.
Please refer to https://hub.docker.com/r/tzutalin/opengrok/

No comments:

Post a Comment