Running OpenGrok on Windows
March 26, 2011 10 Comments
I’ve needed to setup a local OpenGrok server on Windows to do some testing. It’s not that straightforward as one might expect but not that hard either. My setup is not secure nor tested whatsoever so don’t rely on it, but it can be used if you need to quickly setup some OpenGrok server on your Windows workstation. So here’s what you have to do:
- Download OpenGrok binary. Just go to OpenGrok Home and download 0.10 binary
- Download ctags. Just go to ctags, download windows zip file and extract it somewhere.
- Edit web.xml. You need to extract
lib/source.warsomewhere and modify
WEB-INF/web.xmlslightly. I’ve modified
CONFIGURATIONparam to point to my generated
configuration.xmlfile(more about it later) and added
DATA_ROOTto point to folder with sources to index and folder that OpenGrok should keep it’s data in (I’m not sure if these two are needed if you pass in configuration.xml)
<context-param> <param-name>CONFIGURATION</param-name> <param-value>D:/GrokTest/configuration.xml</param-value> <description>Full path to the configuration file where OpenGrok can read it's configuration</description> </context-param> <context-param> <param-name>SRC_ROOT</param-name> <param-value>D:/GrokTest/src</param-value> </context-param> <context-param> <param-name>DATA_ROOT</param-name> <param-value>D:/GrokTest/grokdata</param-value> </context-param>
- Deploy web app on Tomcat 6 (didn’t test it on any other servlet container, but docs state that it should also work on Glassfish and Tomcat later than 6). I’ve just copied
PATH_TO_TOMCAT/webappsbut you can zip them to war and deploy as single file.
- Index source/generate configuration.xml. OpenGrok has nice config generation tool. Just go to
java -jar opengrok.jar -W D:\GrokTest\configuration.xml -c <<path_to_ctags>>\ctags.exe -P -S -v -s D:\GrokTest\src -d D:\GrokTest\grokdata
You can omit -P if you don’t need projects (first level directories are considered projects with this option, not as source folders). This will index your source files and generate
Now start Tomcat
(PATH_TO_TOMCAT\bin\startup.bat) and go to http://localhost:8080/source and if I didn’t forget something 😉 you should see OpenGrok search page with your projects. Try to search, should work fine.
P.S. If you change source you have to re-index and overwrite configuration.xml if you added/removed projects.