【OpenGrok代码搜索引擎】三、OpenGrok常用命令

【OpenGrok代码搜索引擎】三、OpenGrok常用命令写在前面为了防止一些无法预料的情况发生,建议在完成代码项目索引创建后对索引生成器(indexer)生成的配置文件configuration.xml进行备份。一、免配置方法可以使用一个OpenGrokDocker容器,该容器包含了OpenGrok配置环境,但需要注意的是,该容器不适合大型的代码项目。详细参考链接如下:opengrok/dockeratmaster·oracle/opengrok·GitHubDockerHub二、常用命令2…

大家好,又见面了,我是你们的朋友全栈君。

写在前面

        为了防止一些无法预料的情况发生,建议在完成代码项目索引创建后对索引生成器(indexer)生成的配置文件configuration.xml进行备份。

一、免配置方法

可以使用一个OpenGrok Docker容器,该容器包含了OpenGrok配置环境,但需要注意的是,该容器不适合大型的代码项目。

详细参考链接如下:

opengrok/docker at master · oracle/opengrok · GitHub

Docker Hub

二、常用命令

2.1 查看帮助

java -jar /opengrok/dist/lib/opengrok.jar -h

opengrok-indexer -a /opengrok/dist/lib/opengrok.jar — -h

执行结果如下:

Apr 03, 2022 10:21:08 AM org.opengrok.indexer.index.Indexer parseOptions
INFO: Indexer options: [-h]

Usage: java -jar opengrok.jar [options] [subDir1 [...]]

  //帮助参数
  -h, -?, --help [mode]
        With no mode specified, display this usage summary. Or specify a mode:
          config - display configuration.xml examples.
           ctags - display ctags command-line.
            guru - display AnalyzerGuru details.
           repos - display enabled repositories.
  //设置同步API超时
  --apiTimeout number
        Set timeout for asynchronous API requests.

  //设置连接API超时
  --connectTimeout number
        Set connect timeout. Used for API requests.

  //设置分析器支持的格式,如拓展名,前缀等。
  -A, --analyzer (.ext|prefix.):(-|analyzer)
        Associates files with the specified prefix or extension (case-
        insensitive) to be analyzed with the given analyzer, where 'analyzer'
        may be specified using a class name (case-sensitive e.g. RubyAnalyzer)
        or analyzer language name (case-sensitive e.g. C). Option may be
        repeated.
          Ex: -A .foo:CAnalyzer
              will use the C analyzer for all files ending with .FOO
          Ex: -A bar.:Perl
              will use the Perl analyzer for all files starting with
              "BAR" (no full-stop)
          Ex: -A .c:-
              will disable specialized analyzers for all files ending with .c

  //指定ctags路径
  -c, --ctags /path/to/ctags
        Path to Universal Ctags. Default is ctags in environment PATH.

  //指定canonicalRoot路径
  --canonicalRoot /path/
        Allow symlinks to canonical targets starting with the specified root
        without otherwise needing to specify -N,--symlink for such symlinks. A
        canonical root must end with a file separator. For security, a canonical
        root cannot be the root directory. Option may be repeated.

  //检查索引
  --checkIndex
        Check index, exit with 0 on success,
        with 1 on failure.

  //指定OpenGrok数据生成的路径
  -d, --dataRoot /path/to/data/root
        The directory where OpenGrok stores the generated data.

  //指定代码仓扫描目录深度,默认为2
  --depth number
        Scanning depth for repositories in directory structure relative to
        source root. Default is 2.

  //不使能
  --disableRepository type_name
        Disables operation of an OpenGrok-supported repository. See also
        -h,--help repos. Option may be repeated.
          Ex: --disableRepository git
              will disable the GitRepository
          Ex: --disableRepository MercurialRepository

  //节省磁盘空间,OpenGrok不产生和保存超文本交叉引用文件等。
  -e, --economical
        To consume less disk space, OpenGrok will not generate and save
        hypertext cross-reference files but will generate on demand, which could
        be slightly slow.

  -G, --assignTags
        Assign commit tags to all entries in history for all repositories.

  //使能历史信息
  -H, --history
        Enable history.

  --historyThreads number
        The number of threads to use for history cache generation on repository level. By default                                                                                                         the number of threads will be set to the number of available CPUs.
        Assumes -H/--history.

  --historyFileThreads number
        The number of threads to use for history cache generation when dealing with individual fil                                                                                                        es.
        By default the number of threads will be set to the number of available CPUs.
        Assumes -H/--history.

  -I, --include pattern
        Only files matching this pattern will be examined. Pattern supports
        wildcards (example: -I '*.java' -I '*.c'). Option may be repeated.

  -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.

  -l, --lock on|off|simple|native
        Set OpenGrok/Lucene locking mode of the Lucene database during index
        generation. "on" is an alias for "simple". Default is off.

  --leadingWildCards on|off
        Allow or disallow leading wildcards in a search. Default is on.

  -m, --memory number
        Amount of memory (MB) that may be used for buffering added documents and
        deletions before they are flushed to the directory (default 16.0).
        Please increase JVM heap accordingly too.

  --mandoc /path/to/mandoc
        Path to mandoc(1) binary.

  -N, --symlink /path/to/symlink
        Allow the symlink to be followed. Other symlinks targeting the same
        canonical target or canonical children will be allowed too. Option may
        be repeated. (By default only symlinks directly under the source root
        directory are allowed. See also --canonicalRoot)

  -n, --noIndex
        Do not generate indexes and other data (such as history cache and xref
        files), but process all other command line options.

  --nestingMaximum number
        Maximum depth of nested repositories. Default is 1.

  -O, --optimize on|off
        Turn on/off the optimization of the index database as part of the
        indexing step. Default is on.

  -o, --ctagOpts path
        File with extra command line options for ctags.

  -P, --projects
        Generate a project for each top-level directory in source root.

  -p, --defaultProject path/to/default/project
        Path (relative to the source root) to a project that should be selected
        by default in the web application (when no other project is set either
        in a cookie or in parameter). Option may be repeated to specify several
        projects. Use the special value __all__ to indicate all projects.

  --profiler
        Pause to await profiler or debugger.

  --progress
        Print per-project percentage progress information.

  -Q, --quickScan on|off
        Turn on/off quick context scan. By default, only the first 1024KB of a
        file is scanned, and a link ('[..all..]') is inserted when the file is
        bigger. Activating this may slow the server down. (Note: this setting
        only affects the web application.) Default is on.

  -q, --quiet
        Run as quietly as possible. Sets logging level to WARNING.

  -R /path/to/configuration
        Read configuration from the specified file.

  -r, --remote on|off|uionly|dirbased
        Specify support for remote SCM systems.
              on - allow retrieval for remote SCM systems.
             off - ignore SCM for remote systems.
          uionly - support remote SCM for user interface only.
        dirbased - allow retrieval during history index only for repositories
                   which allow getting history for directories.

  --renamedHistory on|off
        Enable or disable generating history for renamed files.
        If set to on, makes history indexing slower for repositories
        with lots of renamed files. Default is off.

  --repository [path/to/repository|@file_with_paths]
        Path (relative to the source root) to a repository for generating
        history (if -H,--history is on). By default all discovered repositories
        are history-eligible; using --repository limits to only those specified.
        File containing paths can be specified via @path syntax.
        Option may be repeated.

  -S, --search [path/to/repository|@file_with_paths]
        Search for source repositories under -s,--source, and add them. Path
        (relative to the source root) is optional.
        File containing paths can be specified via @path syntax.
        Option may be repeated.

  -s, --source /path/to/source/root
        The root directory of the source tree.

  --style path
        Path to the subdirectory in the web application containing the requested
        stylesheet. The factory-setting is: "default".

  -T, --threads number
        The number of threads to use for index generation, repository scan
        and repository invalidation.
        By default the number of threads will be set to the number of available
        CPUs. This influences the number of spawned ctags processes as well.

  -t, --tabSize number
        Default tab size to use (number of spaces per tab character).

  --token string|@file_with_string
        Authorization bearer API token to use when making API calls
        to the web application

  -U, --uri SCHEME://webappURI:port/contextPath
        Send the current configuration to the specified web application.

  --updateConfig
        Populate the web application with a bare configuration, and exit.

  --userPage URL
        Base URL of the user Information provider.
        Example: "https://www.example.org/viewProfile.jspa?username=".
        Use "none" to disable link.

  --userPageSuffix URL-suffix
        URL Suffix for the user Information provider. Default: "".

  -V, --version
        Print version, and quit.

  -v, --verbose
        Set logging level to INFO.

  -W, --writeConfig /path/to/configuration
        Write the current configuration to the specified file (so that the web
        application can use the same configuration).

  --webappCtags on|off
        Web application should run ctags when necessary. Default is off.

2.2 创建/更新索引

java \
    -Djava.util.logging.config.file=/opengrok/etc/logging.properties \
    -jar /opengrok/dist/lib/opengrok.jar \
    -c /usr/local/bin/ctags \
    -s /opengrok/src -d /opengrok/data -H -P -S -G \
    -W /opengrok/etc/configuration.xml -U http://localhost:8080/source

或使用OpenGrok管理工具包中的opengrok-indexer

opengrok-indexer \
    -J=-Djava.util.logging.config.file=/opengrok/etc/logging.properties \
    -a /opengrok/dist/lib/opengrok.jar — \
    -c /usr/local/bin/ctags \
    -s /opengrok/src -d /opengrok/data -H -P -S -G \
    -W /opengrok/etc/configuration.xml -U http://localhost:8080/source

2.3 创建单个项目的索引或新增一个项目的索引

java \
    -Djava.util.logging.config.file=/opengrok/etc/logging.properties \
    -jar /opengrok/dist/lib/opengrok.jar \
    -c /usr/local/bin/ctags \
    -s /opengrok/src -d /opengrok/data -H -S -G -p /opengrok/src/06_systemd \
    -W /opengrok/etc/configuration.xml -U http://localhost:8080/source

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/131415.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • dz搬家 config_global.php 不可写入,傻瓜式Discuz论坛搬家教程

    dz搬家 config_global.php 不可写入,傻瓜式Discuz论坛搬家教程1.首先,数据的备份是很重要的,要明确这一点2.论坛搬家,备份恢复一点也不难,真的,首先不要在心里上被它吓到,dz程序为我们提供了非常便捷的几种方案大致上,搬家的方法有几种:1.第一种方法是通过phpmyadmin导出导入数据,这种方法比较鸡肋,因为超过2M的就上传不上去了,在此不多解释,不推荐2.第二种方法是通过ucenter后台自带备份恢复,这个容易遇到“无法访问该应用的备份接口,请拷贝uce…

    2022年7月25日
    7
  • Python—socket库建议收藏

    为方便以后查询和学习,特从常用库函数和示例来总结socket库1.术语family:AF_INETsocktype:SOCK_STREAM或SOCK_DGRAMprotocol:IPPROT

    2021年12月18日
    53
  • 如何使vmware虚拟机中的Redflag Linux操作系统能够上网?

    如何使vmware虚拟机中的Redflag Linux操作系统能够上网? 第一种情况:主机使用PPPOE拨号上网方法一:NAT方式1、先关闭虚拟机中的操作系统,回到虚拟机主界面双击主界面右上方的的“Ethernet”,弹出“NetworkAdapter”对话框,选择“NAT”2、启动虚拟机操作系统,设置IP为动态获取,即通过DHCP获得。此时虚拟机中的操作系统用的是主机的IP,主机能够上网,那么虚拟机也能。方法二:Host-only方式1

    2022年8月20日
    5
  • Java中的Scanner(详解常见用法)

    Java中的Scanner(详解常见用法)OJ中遇到的问题和例子:doublenextDouble(),floatnextFloat(),intnextInt()等与nextLine()连用时都存在遗留的换行符影响nextLine()读取输入的问题,解决的办法是:在每一个next()、nextDouble()、nextFloat()、nextInt()等语句之后加一个nextLine()语句,将被next()去掉的…

    2022年7月8日
    21
  • idea20.3.1激活码-激活码分享2022.02.17[通俗易懂]

    (idea20.3.1激活码)2021最新分享一个能用的的激活码出来,希望能帮到需要激活的朋友。目前这个是能用的,但是用的人多了之后也会失效,会不定时更新的,大家持续关注此网站~IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.html…

    2022年4月1日
    288
  • MySQL删除约束_mysql查看表字段

    MySQL删除约束_mysql查看表字段一、字段操作1.添加字段(add)altertableadd字段名数据类型;desc;2.修改字段数据类型(modify)altertablemodify;3.字段重命名(change)#新字段名后要加上字段的数据类型,否则报错altertablechange;#可用来修改字段数据类型#也可以在修改数据类型后添加默认值或其它约束条件#可以在最后修改字段位…

    2022年10月12日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号