How to ignore directories in OpenGrok index?
Asked Answered
V

3

7

I am trying to setup OpenGrok to search through a few GB of code, mostly Java and Python projects. I use opengrok-0.12.1/bin/OpenGrok index $SRC_ROOT to build the index. I can see it indexing Java's "target" and Python's ".tox" directories which I don't need.

I searched online and found the same question in many forums, and the answer being to use -i. I have tried to use this option with both the OpenGrok wrapper script as well as opengrok.jar, but all I get is the help message (because the command line options were apparently wrong).

Could you give me an example command to build indices that ignore certain directories?

Verbosity answered 11/3, 2015 at 22:56 Comment(0)
V
8

The solution is to use the -i flag. The best way to do this is to create a .conf file. For example, I have the following file defined as opengrok.conf:

OPENGROK_APP_SERVER=Tomcat
OPENGROK_TOMCAT_BASE=/usr/local/Cellar/tomcat/8.0.21/libexec
OPENGROK_SCAN_DEPTH=4
OPENGROK_VERBOSE=yes
OPENGROK_PROGRESS=yes
IGNORE_PATTERNS="-i f:foo.txt -i *.bar -i d:target -i d:.tox"

And run the indexing using: OPENGROK_CONFIGURATION=opengrok.conf ./OpenGrok index $SRC_ROOT

It ignores indexing the file foo.txt, all files that match the pattern *.bar, and all files in directories named target or .tox.

Edit credits: mrenaud, pcas

Verbosity answered 4/4, 2015 at 1:39 Comment(4)
Directories must be prefixed with d:Dull
Thank you for the suggestion. I don't have enough points to accept your edit, so I update it myself as per your instructions and credited you.Verbosity
Slight typo in IGNORE_PATTERNS="-i f:foo.txt -i *.bar -d:target -i d:.tox" Should read: IGNORE_PATTERNS="-i f:foo.txt -i *.bar -i d:target -i d:.tox"Invaginate
Thank you, @PCas. Fixed it.Verbosity
R
2

Note that https://github.com/oracle/opengrok/pull/1841 renamed IGNORE_PATTERNS to OPENGROK_IGNORE_PATTERNS (in Oct 2017).

Rigel answered 2/5, 2018 at 9:54 Comment(0)
C
2

https://github.com/oracle/opengrok/wiki/How-to-setup-OpenGrok

java -jar opengrok-1.3.16/lib/opengrok.jar --help

  -i, --ignore pattern
        Ignore matching files (prefixed with 'f:' or no prefix) or directories
        (prefixed with 'd:'). Pattern supports wildcards (example: -i '*.so'
        -i d:'test*'). Option may be repeated.

with the new opengrok-tools, it looks like

opengrok-indexer                                                           \
    --java_opts=-Djava.util.logging.config.file=$(OPENGROK_BASE)/etc/logging.properties \
    --jar $(OPENGROK_DIST)/lib/opengrok.jar --                                          \
    --ctags /usr/local/bin/ctags                                                        \
    --source $(PWD)                                                                     \
        --dataRoot $(OPENGROK_BASE)/data                                                    \
        --progress                                                                          \
        --history                                                                           \
        --assignTags                                                                        \
    --writeConfig $(OPENGROK_BASE)/etc/configuration.xml                                \
        --analyzer .sc:ScalaAnalyzer                                                        \
        --ignore 'd:zold'                                                                   \
        --ignore 'd:opengrok'                                                               \
        --ignore 'd:tmp'                                                                    \
        --ignore 'd:.venv'                                                                  \
        --ignore 'd:.ipynb_checkpoints'                                                     \
        --ignore 'd:.metals'                                                                \
    # END

Cristen answered 31/7, 2020 at 16:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.