【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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • kali linux安装教程

    kali linux安装教程这是在虚拟机安装下面是介绍kalilinux***操作系统一、Kali简介1.1、相关连接Kali百度百科:https://baike.baidu.com/item/Kali%20linux/8305689?fr=aladdinKaliwiki:https://en.wikipedia.org/wiki/KaliKali官网:https://www.kali.org/1….

    2022年5月16日
    42
  • c语言findwindow函数_findwindow函数

    c语言findwindow函数_findwindow函数转自:http://blog.csdn.net/coolszy/article/details/5523486[DllImport(“User32.dll”,EntryPoint=”FindWindow”)]句柄,是整个Windows编程的基础。一个句柄是指使用的一个唯一的整数值,即一个4字节(64位程序中为8字节)长的数值,来标识应用程序中的不同对象和同类中的不同的指针,程序不能利用句柄来…

    2022年8月13日
    12
  • NOIP 2008 普及组 传球游戏「建议收藏」

    NOIP 2008 普及组 传球游戏「建议收藏」超时#include<bits/stdc++.h>usingnamespacestd;intn,m,ans;//第cnt次传球后,球在编号为x的同学手上voiddfs(intcnt,intx){ if(cnt==m){ if(x==0)ans++; return; } dfs(cnt+1,(x+1)%n); dfs(cnt+1,(x-1+n)%n); }intmain(){.

    2022年7月14日
    54
  • 怎样让浏览器变身代码编辑器?

    怎样让浏览器变身代码编辑器?将浏览器变成一个简易文本编辑器一开始的功能非常简单,根本没有语法高亮,也没有自动缩进,仅仅是将浏览器变成一个文本编辑器而已。Jose分享的代码如下:data:text/html,htmlcontenteditable>只需要将上面的代码复制粘贴到浏览器的地址栏,然后按回车,就可以让浏览器变成编辑器。是不是非常简单?背后的原理并不高

    2022年6月22日
    38
  • cmake eigen_cmake链接动态库

    cmake eigen_cmake链接动态库在自己的程序中使用Eigen库,用cmake实现

    2022年10月18日
    0
  • Linux 镜像文件下载「建议收藏」

    Linux 镜像文件下载「建议收藏」CENTOS简介和镜像下载一、CENTOS下载各国镜像地址http://www.centos.org/modules/tinycontent/index.php?id=32二、中国大陆镜像部分ChinaCMCCTaianBranch(泰安移动)http://mirrors.ta139.com/centos/ChinaNetEase(163网

    2022年6月28日
    34

发表回复

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

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