精华内容
下载资源
问答
  • OpenGrok 安装说明

    2020-11-19 10:42:19
    ator@ator-hp-prodesk-680-g4-mt:/opt/opengrok-1.1-rc3/doc$ cat README.txt # # Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved. # OpenGrok - a wicked fast source browser ----...

    ator@ator-hp-prodesk-680-g4-mt:/opt/opengrok-1.1-rc3/doc$ cat README.txt
    #

    # Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
    #
    OpenGrok - a wicked fast source browser
    ---------------------------------------

    1.  Introduction
    2.  Requirements
    3.  Usage
    4.  OpenGrok install
    5.  OpenGrok setup
    6.  Optional Command Line Interface Usage
    7.  Change web application properties or name
    8.  Information for developers
    9. Tuning OpenGrok for large code bases
    10. Authors
    11. Contact us


    1. Introduction
    ---------------

    OpenGrok is a fast and usable source code search and cross reference
    engine, written in Java. It helps you search, cross-reference and navigate
    your source tree. It can understand various program file formats and
    version control histories of many source code management systems.

    Offical page of the project is on:

      http://opengrok.github.com/OpenGrok/

    2. Requirements
    ---------------

        * Latest Java (At least 1.8)
          http://www.oracle.com/technetwork/java/
        * A servlet container like Tomcat (8.x or later)
          supporting Servlet 2.5 and JSP 2.1
          http://tomcat.apache.org/
        * Exuberant Ctags or Universal Ctags
          http://ctags.sourceforge.net/
          https://ctags.io/
        * Source Code Management installation
          depending on type of repositories indexed
        * If you want to build OpenGrok:
          - Ant (1.9.4 and later)
            http://ant.apache.org/
          - JFlex
            http://www.jflex.de/
          - Netbeans (optional, at least 8.2, will need Ant 1.9.4)
            http://netbeans.org/

    3. Usage
    --------

    OpenGrok usually runs in servlet container (e.g. Tomcat).

    SRC_ROOT environment variable refers to the directory containing your source
    tree. OpenGrok analyzes the source tree and builds a search index along with
    cross-referenced hypertext versions of the source files. These generated
    data files will be stored in directory referred to with environment variable
    called DATA_ROOT.

    3.1 Projects
    ------------

    OpenGrok has a concept of Projects - one project is one directory underneath
    SRC_ROOT directory which usually contains a checkout of a project sources.
    (this can be branch, version, ...)

    Projects effectively replace the need to have more web applications, each with
    opengrok .war file. Instead it leaves you with one indexer and one web
    application serving multiple source code repositories - projects.
    Then you have a simple update script and simple index refresher script in
    place, which simplifies management of more repositories.

    A nice concept is to have a naming convention for directories underneath
    SRC_ROOT, thereby creating a good overview of projects (e.g.
    name-version-branch).

    For example, the SRC_ROOT directory can contain the following directories:

      openssl-head
      openssl-0.9.8-stable
      openssl-1.0.0-stable

    Each of these directories was created with 'cvs checkout' command (with
    appropriate arguments to get given branch) and will be treated by OpenGrok
    as a project.

    3.2 Messages
    ------------

    Deployed OpenGrok can receive couple of messages through the active socket which
    usually listens for the main configuration file. These are used in the web
    application and displayed to the users. One can easily notify users about some
    important events, for example that the reindex is being in progress and that
    the searched information can be inconsistent.

    The OpenGrok comes with a tool which allows you to send these messages without
    any problem. It is called Messages and it is located under the tools directory.
    See the file for usage and more information.

    3.2.1 Tags
    ----------

    Any message can use tags which makes it more specific for the application.
    Messages which tag match some OpenGrok project are considered project specific
    and the information contained in them are displayed only for the specific projects.

    There is a key tag "main" which is exclusive for displaying
    messages on the OpenGrok landing page - like a common information.

    3.2.2 Types
    -----------

    Currently supported message types:
    1) NormalMessage (normal)
        This message is designed to display some information in the web application.
        Use tags to target a specific project.
    2) AbortMessage (abort)
        This message can delete some already published information in
        the web application.
        Use tags to restrict the deletion only to specific projects.
    3) StatsMessage (stats)
        This message is designed to retrieve some information from the web application.

        The purpose of the message is specified in the text field as one of:
            - "reload"  the application reloads the statistics file
                        and returns the loaded statistics
            - "clean"   the application cleans its current statistics
                        and returns the empty statistics
            - "get"     the application returns current statistics
    4) ConfigMessage (config)
        This message retrieves or sends a configuration to the webapp,
        depending on tag. "setconf" tag sends config to webapp and requires
        file as argument. "set" tag sets particular configuration option in the webapp.
    5) RefreshMesssage (refresh)
        Sent at the end of partial reindex to trigger refresh of SearcherManagers.

    4. OpenGrok install
    -----------------

    4.1 Installing on Solaris from *.p5p file
    -----------------

    4.1.0 Install
    -----------------

    The file <package_name>.p5p you can easily use as a new publisher for the pkg command.

      # pkg install --no-refresh -g /path/to/file/<package_name>.p5p opengrok


    4.1.1 Update
    -----------------

    You can also update OpenGrok software with the *.p5p file by running a command

      # pkg update --no-refresh -g /path/to/file/<package_name>.p5p 'pkg://opengrok/*'


    5. OpenGrok setup
    -----------------

    To setup OpenGrok it is needed to prepare the source code, let OpenGrok index
    it and start the web application.

    5.1 Setting up the sources
    --------------------------

    Source base should be available locally for OpenGrok to work efficiently.
    No changes are required to your source tree. If the code is under source
    control management (SCM) OpenGrok requires the checked out source tree under
    SRC_ROOT.

    By itself OpenGrok does not perform the setup of the source code repositories
    or sychronization of the source code with its origin. This needs to be done by
    the user or by using automatic scripts.

    It is possible for SCM systems which are not distributed (Subversion, CVS)
    to use a remote repository but this is not recommended due to the performance
    penalty. Special option when running the OpenGrok indexer is needed to enable
    remote repository support ("-r on").

    In order for history indexing to work for any SCM system it is necessary
    to have environment for given SCM systems installed and in a path accessible
    by OpenGrok.

    Note that OpenGrok ignores symbolic links.

    If you want to skip indexing the history of a particular directory
    (and all of it's subdirectories), you can touch '.opengrok_skip_history' file
    at the root of that directory.
    If you want to disable history generation for all repositories globally, then
    set OPENGROK_GENERATE_HISTORY environment variable to "off" during indexing.

    5.2 Using Opengrok shell wrapper script to create indexes
    ---------------------------------------------------------

    For *nix systems there is a shell script called OpenGrok which simplifies most
    of the tasks. It has been tested on Solaris and Linux distributions.

    5.2.1 - Deploy the web application
    ----------------------------------

    First please change to opengrok directory where the OpenGrok shell script is
    stored (can vary on your system).

    Note that now you might need to change to user which owns the target
    directories for data, e.g. on Solaris you'd do:

      # pfexec su - webservd
      $ cd /usr/opengrok/bin

    and run

      $ ./OpenGrok deploy

    This command will do some sanity checks and will deploy the source.war in
    its directory to one of detected web application containers.
    Please follow the error message it provides.

    If it fails to discover your container, please refer to optional steps on
    changing web application properties below, which explains how to do this.

    Note that OpenGrok script expects the directory /var/opengrok to be
    available to user running opengrok with all permissions. In root user case
    it will create all the directories needed, otherwise you have to manually
    create the directory and grant all permissions to the user used.

    5.2.2 - Populate DATA_ROOT Directory
    ------------------------------------

    During this process the indexer will generate OpenGrok XML configuration file
    configuration.xml and sends the updated configuration to your web app.

    The indexing can take a lot of time. After this is done, indexer automatically
    attempts to upload newly generated configuration to the web application.
    Most probably you will not be able to use Opengrok before this is done for the
    first time.

    Please change to opengrok directory (can vary on your system)

      $ cd /usr/opengrok/bin

    and run, if your SRC_ROOT is prepared under /var/opengrok/src

      $ ./OpenGrok index

    otherwise (if SRC_ROOT is in different directory) run:

      $ ./OpenGrok index <absolute_path_to_your_SRC_ROOT>

    The above command attempts to upload the latest index status reflected into
    configuration.xml to a running source web application.
    Once above command finishes without errors
    (e.g. SEVERE: Failed to send configuration to localhost:2424),
    you should be able to enjoy your opengrok and search your sources using
    latest indexes and setup.

    It is assumed that any SCM commands are reachable in one of the components
    of the PATH environment variable (e.g. 'git' command for Git repositories).
    Likewise, this should be maintained in the environment of the user which runs
    the web server instance.

    Congratulations, you should now be able to point your browser to
    http://<YOUR_WEBAPP_SERVER>:<WEBAPPSRV_PORT>/source to work with your fresh
    OpenGrok installation! :-)

    At this time we'd like to point out some customization to OpenGrok script
    for advanced users.
    A common case would be, that you want the data in some other directory than
    /var/opengrok. This can be easily achieved by using environment variable
    OPENGROK_INSTANCE_BASE.

    E.g. if opengrok data directory is /tank/opengrok and source root is
    in /tank/source then to get more verbosity run the indexer as:

      $ OPENGROK_VERBOSE=true OPENGROK_INSTANCE_BASE=/tank/opengrok \
           ./OpenGrok index /tank/source

    Since above will also change default location of config file, beforehands(or
    restart your web container after creating this symlink) I suggest doing
    below for our case of having opengrok instance in /tank/opengrok :

      $ ln -s /tank/opengrok/etc/configuration.xml \
          /var/opengrok/etc/configuration.xml

    More customizations can be found inside the script, you just need to
    have a look at it, eventually create a configuration out of it and use
    OPENGROK_CONFIGURATION environment variable to point to it. Obviously such
    setups can be used for nightly cron job updates of index or other automated
    purposes.

    5.2.3 Partial reindex
    ---------------------

    There is inherent time window between after the source code is updated
    (highlighted in step 5.1 above) and before indexer completes. During this
    time window the index does not match the source code. To alleviate this
    limitation, one can kick off update of all source repositories in
    parallel and once all the mirroring completes perform complete reindex.
    This does not really help in case when some of the source code
    repositories are slow to sync, e.g. because the latency to their origin is
    significant, because the overall mirroring process has to wait for all the
    projects to finish syncing before running the indexer. To overcome this
    limitation, the index of each project can be created just after the
    mirroring of this project finishes.

    Thus, the overall approach would be:

      1. create initial index of all the source code

         This will produce configuration.xml, optionally by combining the
         discovered projects with read-only configuration (as specified
         with OPENGROK_READ_XML_CONFIGURATION). This step has to be performed
         only once - during the initial OpenGrok setup.

      2. mirror and index all projects in parallel

         This is done by running indexpart command of the OpenGrok script and
         specifying the configuration.xml written in previous step as
         OPENGROK_READ_XML_CONFIGURATION. The configuration will help the indexer
         to discover source/data root and project to source path mapping.

      3. perform complete reindex (like in step 1)

         Once all the pre-existing projects are mirrored and indexed, run full
         indexer to discover projects which have been added or deleted.
         This will produce new configuration.xml.

    When running the indexer the logs are being written to single file. Since
    multiple indexers are being run in parallel in step 2, their logs have to
    be separated. To do this, create logging.properties file for each project
    using the /var/opengrok/logging.properties file as template. The only line
    which can differ would be this:

    java.util.logging.FileHandler.pattern = /var/opengrok/log/myproj/opengrok%g.%u.log

    Note the path component 'myproj' which separates the logs for given
    project to this directory. The creation of the per-project directory and the
    logging.properties file can be easily done in a script.

    The command used in step 2 can look like this:

      OPENGROK_LOGGER_CONFIG_PATH=/var/opengrok/myproj.logging \
         OPENGROK_READ_XML_CONFIGURATION=/var/opengrok/etc/configuration.xml \
         OpenGrok indexpart /myproj

    The last argument is path relative to SRC_ROOT.

    5.3 Using SMF service (Solaris) to maintain OpenGrok indexes
    ------------------------------------------------------------

    If you installed OpenGrok from the OSOLopengrok package, it will work out of
    the box. Should you need to configure it (e.g. because of non-default SRC_ROOT
    or DATA_ROOT paths) it is done via the 'opengrok' property group of the
    service like this:

      # svccfg -s opengrok setprop \
           opengrok/srcdir="/absolute/path/to/your/sourcetree"
      # svccfg -s opengrok setprop opengrok/maxmemory="2048"

    Then make the service start the indexing, at this point it would be nice if
    the web application is already running.

    Now enable the service:

      # svcadm enable -rs opengrok

    Note that this will enable tomcat service as dependency.

    When the service starts indexing for first time, it's already enabled and
    depending on tomcat, so at this point the web application should be
    already running.

    Note that indexing is not done when the opengrok service is disabled.

    To rebuild the index later (e.g. after source code changed) just run:

      # svcadm refresh opengrok

    The service makes it possible to supply part of the configuration via the
    'opengrok/readonly_config' service property which is set to
    /etc/opengrok/readonly_configuration.xml by default.

    Note: before removing the package please disable the service.
    If you don't do it, it will not be removed automatically.
    In such case please remove it manually.

    5.4 Using command line interface to create indexes
    --------------------------------------------------

    There are 2 (or 3) steps needed for this task.

    5.4.1 - Populate DATA_ROOT Directory
    ------------------------------------

    Option 1. OpenGrok: There is a sample shell script OpenGrok that is suitable
    for using in a cron job to run regularly. Modify the variables in the script
    to point appropriate directories, or as the code suggests factor your local
    configuration into a separate file and simplify future upgrades.

    Option 2. opengrok.jar: You can also directly use the Java application. If
    the sources are all located in a directory SRC_ROOT and the data and
    hypertext files generated by OpenGrok are to be stored in DATA_ROOT, run

         $ java -jar opengrok.jar -s $SRC_ROOT -d $DATA_ROOT

    See opengrok.jar manual below for more details.

    5.4.2 - Configure and Deploy source.war Webapp
    ----------------------------------------------

    To configure the webapp source.war, look into the parameters defined in
    web.xml of source.war file and change them (see note1) appropriately.

        * HEADER: is the fragment of HTML that will be used to display title or
                  logo of your project
        * SRC_ROOT: absolute path name of the root directory of your source tree
        * DATA_ROOT: absolute path of the directory where OpenGrok data
                     files are stored

      - File 'header_include' can be created under DATA_ROOT.
        The contents of this file will be appended to the header of each
        web page after the OpenGrok logo element.
      - File 'footer_include' can be created under DATA_ROOT.
        The contents of this file will be appended to the footer of each
        web page after the information about last index update.
      - The file 'body_include' can be created under DATA_ROOT.
        The contents of this file will be inserted above the footer of the web
        application's "Home" page.
      - The file 'error_forbidden_include' can be created under DATA_ROOT.
        The contents of this file will be displayed as the error page when
        the user is forbidden to see a particular project with HTTP 403 code.


    5.4.3 - Path Descriptions (optional)
    ------------------------------------

    OpenGrok can use path descriptions in various places (e.g. while showing
    directory listings or search results). Example descriptions are in paths.tsv
    file (delivered as /usr/opengrok/doc/paths.tsv by OpenGrok package on Solaris).
    The paths.tsv file is read by OpenGrok indexing script from the configuration
    directory (the same where configuration.xml is located) which will create file
    dtags.eftar in the index subdirectory under DATA_ROOT directory which will
    then be used by the webapp to display the descriptions.

    The file contains descriptions for directories one per line. Path to the
    directory and its description are separated by tab. The path to the directory
    is absolute path under the SRC_ROOT directory.

    For example, if the SRC_ROOT directory contains the following directories:

    foo
    bar
    bar/blah
    random
    random/code

    then the paths.tsv file contents can look like this:

    /foo    source code for foo
    /bar    source code for bar
    /bar/blah    source code for blah

    Note that only some paths can have a description.

    5.4.4 - Changing webapp parameters (optional)
    ---------------------------------------------

    web.xml is the deployment descriptor for the web application. It is in a Jar
    file named source.war, you can change it as follows:

        * Option 1: Unzip the file to TOMCAT/webapps/source/ directory and
         change the source/WEB-INF/web.xml and other static html files like
         index.html to customize to your project.

        * Option 2: Extract the web.xml file from source.war file

         $ unzip source.war WEB-INF/web.xml

         edit web.xml and re-package the jar file.

         $ zip -u source.war WEB-INF/web.xml

         Then copy the war files to <i>TOMCAT</i>/webapps directory.

        * Option 3: Edit the Context container element for the webapp

         Copy source.war to TOMCAT/webapps

         When invoking OpenGrok to build the index, use -w <webapp> to set the
         context. If you change this(or set using OPENGROK_WEBAPP_CONTEXT) later,
         FULL clean reindex is needed.

         After the index is built, there's a couple different ways to set the
         Context for the servlet container:
         - Add the Context inside a Host element in TOMCAT/conf/server.xml

         <Context path="/<webapp>" docBase="source.war">
            <Parameter name="DATA_ROOT" value="/path/to/data/root" override="false" />
            <Parameter name="SRC_ROOT" value="/path/to/src/root" override="false" />
            <Parameter name="HEADER" value='...' override="false" />
         </Context>

         - Create a Context file for the webapp

         This file will be named `<webapp>.xml'.

         For Tomcat, the file will be located at:
         `TOMCAT/conf/<engine_name>/<hostname>', where <engine_name>
         is the Engine that is processing requests and <hostname> is a Host
         associated with that Engine.  By default, this path is
         'TOMCAT/conf/Catalina/localhost' or 'TOMCAT/conf/Standalone/localhost'.

         This file will contain something like the Context described above.

    5.4.5 Custom ctags configuration
    --------------------------------

    To make ctags recognize additional symbols/definitions/etc. it is possible to
    specify configuration file with extra configuration options for ctags.

    This can be done by setting OPENGROK_CTAGS_OPTIONS_FILE environment variable
    when running the OpenGrok shell script (or directly with the -o option for
    opengrok.jar). Default location for the configuration file in the OpenGrok
    shell script is etc/ctags.config under the OpenGrok base directory (by default
    the full path to the file will be /var/opengrok/etc/ctags.config).

    Sample configuration file for Solaris code base is delivered in the doc/
    directory.

    5.6 Introduce own mapping for an extension to analyzer
    ------------------------------------------------------

    OpenGrok script doesn't support this out of box, so you'd need to add it there.
    Usually to StdInvocation() function after line -jar ${OPENGROK_JAR} .
    It would look like this:
    -A cs:org.opensolaris.opengrok.analysis.PlainAnalayzer
    (this will map extension .cs to PlainAnalyzer)
    You should even be able to override OpenGroks analyzers using this option.


    6. Optional Command Line Interface Usage
    ----------------------------------------

    You need to pass location of project file + the query to Search class, e.g.
    for fulltext search for project with above generated configuration.xml you'd
    do:

      $ java -cp ./opengrok.jar org.opensolaris.opengrok.search.Search -R \
            /var/opengrok/etc/configuration.xml -f fulltext_search_string

     For quick help run:

      $ java -cp ./opengrok.jar org.opensolaris.opengrok.search.Search

    7. Change web application properties or name
    --------------------------------------------

    You might need to modify the web application if you don't store the
    configuration file in the default location
    (/var/opengrok/etc/configuration.xml).

    To configure the webapp source.war, look into the parameters defined in
    WEB-INF/web.xml of source.war (use jar or zip/unzip or your preferred zip
    tool to get into it - e.g. extract the web.xml file from source.war ($ unzip
    source.war WEB-INF/web.xml) file, edit web.xml and re-package the jar file
    (zip -u source.war WEB-INF/web.xml) ) file and change those web.xml
    parameters appropriately. These sample parameters need modifying(there are
    more options, refer to manual or read param comments).

        * CONFIGURATION - the absolute path to XML file containing project
        * configuration (e.g. /var/opengrok/etc/configuration.xml )
        * ConfigAddress - port for remote updates to configuration, optional,
        * but advised(since there is no authentication) to be set to
        * localhost:<some_port> (e.g. localhost:2424), if you choose some_port
        * below 1024 you have to have root privileges

    If you need to change name of the web application from source to something
    else you need to use special option -w <new_name> for indexer to create
    proper xrefs, besides changing the .war file name. Be sure that when this
    changed you reindex cleanly from scratch. Examples below show just
    deploying source.war, but you can use it to deploy your new_name.war too.

    Deploy the modified .war file in glassfish/Sun Java App Server:

      * Option 1: Use browser and log into glassfish web administration interface

        Common Tasks / Applications / Web Applications , button Deploy and point
        it to your source.war webarchive

      * Option 2: Copy the source.war file to
        GLASSFISH/domains/YOURDOMAIN/autodeploy directory, glassfish will try
        to deploy it "auto magically".

      * Option 3: Use cli from GLASSFISH directory:

        # ./bin/asadmin deploy /path/to/source.war

    Deploy the modified .war file in tomcat:

      * just copy the source.war file to TOMCAT_INSTALL/webapps directory.


    8. Information for developers
    -----------------------------

    8.0 Building
    ------------

    Just run 'ant' from command line in the top-level directory or use build
    process driven by graphical developer environment such as Netbeans.

    Note: in case you are behind http proxy, use ANT_OPTS to download jflex, lucene
    E.g. $ ANT_OPTS="-Dhttp.proxyHost=?.? -Dhttp.proxyPort=80" ant


    8.0.1 Package build
    -------------------

    Run 'ant package' to create package (specific for the operating system this is
    being executed on) under the dist/ directory.

    8.1 Unit testing
    ----------------

    Note: For full coverage report your system has to provide proper junit test
    environment, that would mean:

      - you have to use Ant 1.9 and above
      - at least junit-4.12.jar has to be in ant's classpath (e.g. in ./lib)

      - your PATH must contain directory with exuberant ctags binary
        - Note: make sure that the directory which contains exuberant ctags binary
          is prepended before the directory with plain ctags program.
      - your PATH variable must contain directories which contain binaries of
        appropriate SCM software which means commands hg, sccs, cvs, git, bzr, svn
        (svnadmin too). They must be available for the full report.

    The tests are then run as follows:

      $ ant -lib ./lib test

    To check if the test completed without error look for AssertionFailedError
    occurences in the TESTS-TestSuites.xml file produced by the test run.

    8.2 Using Findbugs
    ------------------

    If you want to run Findbugs (http://findbugs.sourceforge.net/) on OpenGrok,
    you have to download Findbugs to your machine, and install it where you have
    checked out your OpenGrok source code, under the lib/findbugs directory,
    like this:

      $ cd ~/.ant/lib
      $ wget http://..../findbugs-x.y.z.tar.gz
      $ gtar -xf findbugs-x.y.z.tar.gz
      $ mv findbugs-x.y.z findbugs

    You can now run ant with the findbugs target:

      $ ant findbugs
      ...
      findbugs:
       [findbugs] Executing findbugs from ant task
       [findbugs] Running FindBugs...
       [findbugs] Warnings generated: nnn
       [findbugs] Output saved to findbugs/findbugs.html

    Now, open findbugs/findbugs.html in a web-browser, and start fixing bugs !

    If you want to install findbugs some other place than ~/.ant/lib, you can
    untar the .tar.gz file to a directory, and use the findbugs.home property to
    tell ant where to find findbugs, like this (if you have installed fundbugs
    under the lib directory):

      $ ant findbugs -Dfindbugs.home=lib/findbug

    There is also a findbugs-xml ant target that can be used to generate XML files
    that can later be parsed, e.g. by Jenkins.

    8.3 Using Jacoco
    --------------

    If you want to check test coverage on OpenGrok, download jacoco from
    http://www.eclemma.org/jacoco/. Place jacocoagent.jar and jacocoant.jar in the
    opengrok/lib ~/.ant/lib or into classpath (-lib option of ant).

    Now you can instrument your classes and test them run:

      $ ant -Djacoco=true -Djacoco.home=/<path_to>/jacoco jacoco-code-coverage

    Now you should get output data in jacoco.exec

    Look at jacoco/index.html to see how complete your tests are.

    8.4 Using Checkstyle
    --------------------

    To check that your code follows the standard coding conventions,
    you can use checkstyle from http://checkstyle.sourceforge.net/

    First you must download checkstyle from http://checkstyle.sourceforge.net/ ,
    You need Version 6.8 (or newer). Extract the package you have
    downloaded, and create a symbolic link to it from ~/.ant/lib/checkstyle,
    e.g. like this:

       $ cd ~/.ant/lib
       $ unzip ~/Desktop/checkstyle-7.6.zip
       $ ln -s checkstyle-7.6 checkstyle

    You also have to create symbolic links to the jar files:

       $ cd checkstyle
       $ ln -s checkstyle-7.6-all.jar checkstyle-all.jar

    To run checkstyle on the source code, just run ant checkstyle:

       $ ant checkstyle

    Output from the command will be stored in the checkstyle directory.

    If you want to install checkstyle some other place than ~/.ant/lib, you can
    untar the .tar.gz file to a directory, and use the checkstyle.home property
    to tell ant where to find checkstyle, like this (if you have installed
    checkstyle under the lib directory):

      $ ant checkstyle -Dcheckstyle.home=lib/checkstyle

    8.5 Using PMD and CPD
    ---------------------

    To check the quality of the OpenGrok code you can also use PMD
    from https://pmd.github.io/ .

    How to install:

      $ cd ~/.ant/lib
      $ unzip ~/Desktop/pmd-bin-5.5.4.zip
      $ ln -s pmd-5.5.4/ pmd

    To run PMD on the source code, just run ant pmd:

      $ ant -Dpmd.home=~/.ant/lib/pmd pmd

    Output from the command will be stored in the pmd subdirectory:

      $ ls pmd
      pmd_report.html  pmd_report.xml

    If you want to install PMD some other place than ~/.ant/lib, you can
    unzip the .zip file to a directory, and use the pmd.home property
    to tell ant where to find PMD, like this (if you have installed
    PMD under the ./ext_lib directory):

      $ ant pmd -Dpmd.home=ext_lib/pmd

    To run CPD, just use the same as above, but use targets:

      $ ant -Dpmd.home=ext_lib/pmd cpd cpd-xml

    Which will result in:

      $ ls pmd
      cpd_report.xml cpd_report.txt

    8.6 Using JDepend
    -----------------

    To see dependencies in the source code, you can use JDepend from
    https://github.com/clarkware/jdepend .

    How to install:

      $ cd ~/.ant/lib
      $ unzip ~/Desktop/jdepend-2.9.1.zip
      $ ln -s jdepend-2.9.1/ jdepend
      $ cd jdepend/lib
      $ ln -s jdepend-2.9.1.jar jdepend.jar

    How to analyze:

      $ ant jdepend

    Output is stored in the jdepend directory:

      $ ls jdepend/
      report.txt  report.xml

    8.7 Using SonarQube
    -------------------

    Use a sonar runner with included sonar-project.properties properties,
    e.g. using bash:

      $ cd <checkout_dir> # it has to contain sonar-project.properties!
      $ export SONAR_RUNNER_OPTS="-Xmx768m -XX:MaxPermSize=256m"
      $ export SERVERIP=10.163.26.78
      $ ~//Projects/sonar-runner-2.3/bin/sonar-runner \
        -Dsonar.host.url=http://${SERVERIP}:9000
        -Dsonar.jdbc.url=jdbc:h2:tcp://${SERVERIP}:9092/sonar

    8.8 Using Travis CI
    -------------------

    Travis depends on updated and working maven build.
    Please see .travis.yml, if your branch has this file,
    you should be able to connect your Github to Travis CI.
    OpenGroks Travis is here: https://travis-ci.org/OpenGrok/OpenGrok


    8.9 Maven
    ------------------
    The build can now be done through Maven (https://maven.apache.org/) which takes care of the dependency management
    and setup (calls Ant for certain actions).


    8.9.1 Unit Testing
    -------------------------
    You can test the code at the moment by running `./mvn test` which will execute *all* tests.
    Conditionally, if you don't have every type of repository installed, you can set it to unit-test only those which are
    found to be working on your system.

    > ./mvnw test -Djunit-force-all=false

    You can also force a specific repository test from running through the following system property

    > ./mvnw test -Djunit-force-all=false -Djunit-force-git=true

    9. Tuning OpenGrok for large code bases
    ---------------------------------------

    9.1 Almost atomic index flip using ZFS
    ---------------------------------------

    While indexing big source repos you might consider using ZFS filesystem to give
    you advantage of datasets which can be flipped over or cloned when needed.
    If the machine is strong enough it will also give you an option to
    incrementally index in parallel to having the current sources and index in sync.
    (So Tomcat sees certain zfs datasets, then you just stop it, flip datasets to
    the ones that were updated by SCM/index and start tomcat again - outage is
    minimal, sources+indexes are ALWAYS in sync, users see the truth)

    9.2 JVM tuning
    ---------------

    OpenGrok script by default uses 2G of heap and 16MB per thread for flush size of
    lucene docs indexing(when to flush to disk).
    It also uses default 32bit JRE.
    This MIGHT NOT be enough. You might need to consider this:
    Lucene 4.x sets indexer defaults:

     DEFAULT_RAM_PER_THREAD_HARD_LIMIT_MB = 1945;
     DEFAULT_MAX_THREAD_STATES = 8;
     DEFAULT_RAM_BUFFER_SIZE_MB = 16.0;

     - which might grow as big as 16GB (though DEFAULT_RAM_BUFFER_SIZE_MB shouldn't
     really allow it, but keep it around 1-2GB)

     - the lucenes RAM_BUFFER_SIZE_MB can be tuned now using the parameter -m, so
    running a 8GB 64 bit server JDK indexer with tuned docs flushing(on Solaris 11):

     # export JAVA=/usr/java/bin/`isainfo -k`/java
     (or use /usr/java/bin/amd64/java )
     # export JAVA_OPTS="-Xmx8192m -server"
     # OPENGROK_FLUSH_RAM_BUFFER_SIZE="-m 256" ./OpenGrok index /source

    Tomcat by default also supports only small deployments. For bigger ones you
    MIGHT need to increase its heap which might necessitate the switch to 64-bit
    Java. It will most probably be the same for other containers as well.
    For tomcat you can easily get this done by creating conf/setenv.sh:

     # cat conf/setenv.sh
     # 64-bit Java
     JAVA_OPTS="$JAVA_OPTS -d64 -server"

     # OpenGrok memory boost to cover all-project searches
     # (7 MB * 247 projects + 300 MB for cache should be enough)
     # 64-bit Java allows for more so let's use 8GB to be on the safe side.
     # We might need to allow more for concurrent all-project searches.
     JAVA_OPTS="$JAVA_OPTS -Xmx8g"

     export JAVA_OPTS

    9.3 Tomcat/Apache tuning
    -------------------------

    For tomcat you might also hit a limit for http header size (we use it to send
    the project list when requesting search results):
     - increase(add) in conf/server.xml maxHttpHeaderSize
      connectionTimeout="20000"
     maxHttpHeaderSize="65536"
      redirectPort="8443" />

    Refer to docs of other containers for more info on how to achieve the same.

    The same tuning to Apache can be done with the LimitRequestLine directive:

      LimitRequestLine 65536
      LimitRequestFieldSize 65536

    9.4 Open File and processes hard and soft limits
    -----------------------------------

    The initial index creation process is resource intensive and often the error
    "java.io.IOException: error=24, Too many open files" appears in the logs. To
    avoid this increase the ulimit value to a higher number.

    It is noted that the hard and soft limit for open files of 10240 works for mid
    sized repositores and so the recommendation is to start with 10240.

    If you get a similar error, but for threads:
    "java.lang.OutOfMemoryError: unable to create new native thread "
    it might be due to strict security limits and you need to increase the limits.

    9.5 Multi-project search speed tip
    -----------------------------------

    If multi-project search is performed frequently, it might be good to warm
    up file system cache after each reindex. This can be done e.g. with
    https://github.com/hoytech/vmtouch


    10. Authors
    -----------

    The project has been originally conceived in Sun Microsystems by Chandan B.N.

    Chandan B.N, (originally Sun Microsystems) http://blogs.oracle.com/chandan/
    Trond Norbye, norbye.org
    Knut Pape, eBriefkasten.de
    Martin Englund, (originally Sun Microsystems)
    Knut Anders Hatlen, Oracle. http://blogs.oracle.com/kah/
    Lubos Kosco, Oracle. http://blogs.oracle.com/taz/
    Vladimir Kotal, Oracle. http://blogs.oracle.com/vlad/

    11. Contact us
    --------------

    Feel free to participate in discussion on the mailing lists:

      opengrok-users@yahoogroups.com (user topics)
      opengrok-dev@yahoogroups.com (developers' discussion)

    To subscribe, send email to <mailing_list_name>-subscribe@yahoogroups.com


     

    展开全文
  • OpenGrok安装

    2017-01-21 22:35:41
    windows安装OpenGrok安装需要的几个工具 1. JDK 2. tomcat 3. opengrk 4. ctags1.软件安装 1.1 安装JDK 下载地址: http://www.Oracle.com/technetwork/Java/javase/downloads/index.html 从以上下载地址...

    windows安装OpenGrok安装需要的几个工具
    1. JDK
    2. tomcat
    3. opengrk
    4. ctags

    1.软件安装
    1.1 安装JDK
    下载地址:
    http://www.Oracle.com/technetwork/Java/javase/downloads/index.html
    从以上下载地址下载并安装。

    配置环境变量,我安装在H盘的,如下:
    JAVA_HOME H:\program\Java\jdk1.8.0_111
    JRE_HOME H:\program\Java\jdk1.8.0_111
    path添加 H:\program\Java\jdk1.8.0_111\bin
    备注:tomcat启动时要求设置了这两个环境变量。
    这里写图片描述
    验证:
    安装完后,在命令行下输入java -version。如果显示了java的版本信息,则证明java安装成功。

    1.2 安装tomcat
    下载地址:http://tomcat.apache.org/
    从以上地址下载并tomcat,一直点next即可

    安装路径如下
    C:\Program Files\Apache Software Foundation\Tomcat 7.0
    验证:
    在浏览器中输入以下网址并回车: localhost:8080。如果无误,将出现tomcat的介绍页面。

    1.3 安装ctags
    下载地址:http://prdownloads.sourceforge.net/ctags/ctags58.zip
    从以上地址中下载ctags,并解压到合适的路径

    H:\program\ctags58
    Note:把此路径添加到环境变量path

    1.4 安装opengrok
    (1)下载地址: http://opengrok.github.io/OpenGrok/
    从以上地址中下载opengrok的binary发布版本,解压到合适的路径

    H:\program\opengrok-0.12.1

    1.5配置:
    (1)在opengrok的安装目录下新建data和source两个文件夹,source目录用于放置源码,data目录用于放置生成的索引数据;

    (2)把要建立索引的源代码拷贝到(2)中建立的source目录下

    (3)在命令行下输入以下命令并执行,用于生成索引数据,等待命令执行完毕;(若提示错误,检查配置的环境变量是否OK,命令中涉及到的路径根据自己工具安装路径更改路径,注意路径中双反斜杠”\\”);

    java -Xmx524m -jar "H:\\program\\opengrok-0.12.1\\lib\\opengrok.jar" -W "H:\\program\\opengrok-0.12.1\\data\\configuration.xml" -P -S -v -s "H:\\program\\opengrok-0.12.1\\source" -d "H:\\program\\opengrok-0.12.1\\data"

    (4)上述命了执行成功后,会在opengrok安装目录下的lib目录中生成source.war文件,data目录中生成configuration.xml,把source.war拷贝到tomcat安装目录下的webapps目录下

    (5)在浏览器中输入 localhost:8080,并按下回车,这是tomcat安装目录webapps目录下会多一个source文件夹

    (6)修改tomcat安装目录下的webapps\source\WEB-INF**web.xml**
    ,配置configuration.xml的路径

    修改内容如下:
      <display-name>OpenGrok</display-name>
      <description>A wicked fast source browser</description>
      <context-param>
        <param-name>CONFIGURATION</param-name>
        <param-value>H:\program\opengrok-0.12.1\data\configuration.xml</param-value>
        <description>Full path to the configuration file where OpenGrok can read it's configuration</description>
      </context-param>

    (7)安装完成,启动tomcat,在浏览器中输入localhost:8080/source,即可使用opengrok进行代码浏览和搜索了。
    这里写图片描述

    展开全文
  • opengrok镜像离线包,opengrok是一款开源的源代码检索,查看工具,资源为其docker镜像版打包,使用docker load进行加载,之后进行相关run操作启动服务,因为大小有限制,分段上传,下载之后请进行cat合并 成tar格式
  • opengrok镜像离线包

    2020-12-03 12:10:29
    opengrok镜像离线包,opengrok是一款开源的源代码检索,查看工具,资源为其docker镜像版打包,使用docker load进行加载,之后进行相关run操作启动服务,因为大小有限制,分段上传,下载之后请进行cat合并 成tar格式
  • Linux下Opengrok安装部署与使用

    千次阅读 2014-05-12 21:50:37
    OpenGrok 简单安装配置说明

    Opengrok 用于管理多项目的代码非常方便。本文以Opengrok 0.12.1来讲解在RedHat Enterprise Linux上的部署

    http://opengrok.github.io/OpenGrok/

    软件依赖准备:

    1 JAVA                          http://www.oracle.com/technetwork/java//

    2. Tomcat                    http://tomcat.apache.org/

    3.Exuberant Ctags    http://ctags.sourceforge.net/

    下载安装

    1. 上Opengrok官网下载安装包 OpenGrok-0.12.1.tar.gz
    2. root 用户登录 linux server
    3. 将OpenGrok-0.12.1.tar.gz 通过FTP上传到linux server
    4. 解压tar包到安装目录即完成安装 ,一般安装在/opt/opengrok-0.12.1
    tar -xvf OpenGrok-0.12.1.tar.gz   

    OpenGrok使用

    利用OpenGrok 建立源代码索引前需要启动tomcat。OpenGrok的配置文件为 /opt/opengrok-0.12.1/etc/configuration.xml

    配置准备:
    1. 配置必须的环境变量
    export JAVA_HOME=/opt/java
    export OPENGROK_TOMCAT_BASE=/opt/tomcat/
    export OPENGROK_APP_SERVER=Tomcat
    export OPENGROK_INSTANCE_BASE=/opt/opengrok-0.12.1
    export LANG=zh_CN.gb2312  (可选,但中文编码与源代码不一致会产生乱码)

    2.  配置源代码目录
    vi /opt/opengrok-0.12.1/bin/OpenGrok
    找到 SRC_ROOT 配置, 将值设为源代码目录

    建议索引:
    1. 源码opengrok网站发布
    ./opt/opengrok-0.12.1/bin/OpenGrok deploy

    2. 索引源代码
    ./opt/opengrok-0.12.1/bin/OpenGrok index

    完工~ 登录http://xxx.xxx.xxx.xxx:8080/source 即可查看源码


    展开全文
  • Opengrok安装及使用

    千次阅读 2018-09-29 11:26:45
    文章目录一、安装oracle java 8二、安装tomcat8三、安装opengrok四、配置opengrok五、卸载Opengrok六、常见问题七、更多帮助 Opengrok是一款配置非常方便的读代码工具。其便利性的最根本原因是它是基于web运行的,也...
    一、安装oracle java 8
    二、安装tomcat8
    三、安装opengrok
    四、配置opengrok
    五、卸载opengrok
    六、常见问题
    七、更多帮助
    

    Opengrok是一款配置非常方便的读代码工具。其便利性的最根本原因是它是基于web运行的,也就是说只要有一个web服务器,搭建好opengrok之后,你可以通过电脑或者手机的浏览器随时随地的看代码。

    此外,它还有如下优点:
    1. 可使用正则表达式搜索关键字;
    2. 可方便的打开多个网页对照看代码,而不像vi或者source insight一样需要跳转,后退来查看;
    3. 支持多种代码管理工具(git、svn等),可方便查看提交历史,提交diff,每行代码的提交SHA1。

    当然,由于其便捷的访问方式,其缺点也是显而易见的:它不支持账号管理,任何知道服务器信息的人都可以通过链接查看代码。如果你的代码不愿意公开,那么你只能将其搭建于内部服务器上,然后通过VPN访问。

    废话少说,先上两张截图来对其有一个直观的印象:
    index

    diff

    下面我们以ubuntu 上安装为例,来详细介绍Opengrok的安装及使用。
    环境需求:
    1. Ubuntu系统
    2. python3执行环境

    一、安装oracle java 8

    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update
    sudo apt-get install oracle-java8-installer
    sudo apt-get install oracle-java8-set-default
    

    二、安装tomcat8

    1. 命令行安装

      sudo apt-get install tomcat8 -y

    2. 源码安装

       sudo add-apt-repository ppa:webupd8team/java
       sudo apt-get update
       sudo apt-get install oracle-java8-installer
       sudo apt-get install oracle-java8-set-default </code></pre>
    

    请点击此处继续阅读


    想第一时间查看我的文章吗?请关注我的微信公众号号,搜索“落木萧萧技术论坛”或登陆我的个人博客:www.luomuxiaoxiao.com,更多精彩文章等你。

    qrcode
    展开全文
  • Ubuntu下opengrok安装

    千次阅读 2016-11-06 22:04:15
     3.2 解压缩,这里需要提醒一下,为了减少因为权限问题而造成的麻烦,最好把Tomcat和opengrok安装在自己有权限的目录下,执行以下命令,完成解压  tar -xvf apache-tomcat-6.0.44.tar.gz  3.3 解压后进入...
  • ubuntu16.04下opengrok安装

    千次阅读 2018-01-12 11:14:10
    系统环境 ubuntu16.04 安装步骤 安装exuberant-ctags tomcat8 sudo apt-get install exuberant-ctags tomcat8 sudo /etc/init.d/tomcat8 restart ...测试是否安装成功 ...下载opengrok
  • 2. OpenGrok安装和设置 参见 2. 1.更新 OpenGrok使用,版本组件进一步指示有关更新到较新版本的更多详细信息。 版本方案为xyz,任何组件的更改均解释为: x-主要向后不兼容的更新 y-需要对存储库进行完全干净的重新...
  • ubuntu 14.04 opengrok安装及配置

    千次阅读 2016-08-22 15:56:48
    参考官网:http://opengrok.github.io/OpenGrok/ 1. 下载stable 版本  https://github.com/OpenGrok/OpenGrok/files/213268/opengrok-0.12.1.5.tar.gz 2. 环境  container:tomcat7,安装在/usr/local/tomcat7  ...
  • Apache Tomcat+OpenGrok 安装配置

    千次阅读 2015-02-07 16:20:53
    之前有过一段web应用开发的经历,最近想要能够通过一种尽量快的方式来检索...OpenGrok, 配置完成记录一下[ubuntu 12.04]. 1.安装JDK 1.7  sudo apt-get install openjdk-7-jdk  vi /etc/profile 将export JAVA_HOM
  • Ubuntu 搭建opengrok 流程

    2021-10-16 13:19:26
    opengrok平台搭建流程 软件下载链接: https://pan.baidu.com/s/1kCeXNlj2l3FujyMza3rM0w 提取码: iniy 搭建前的准备 电脑系统 电脑系统推荐使用ubuntu 16,这版系统较为稳定。细节未更新 python环境 推荐使用python ...
  • opengrok工具

    2018-04-04 10:12:11
    windows10 搭建opengrok工具和自己写的文档,绝对值,包含jdk tomcat opengrok ctag
  • [原创]OpenGrok安装与配置(大桥加加)

    千次阅读 2014-08-20 13:39:55
    [原创]OpenGrok安装与配置(大桥加加) 在ubuntu12.04LTS (64bit)上,搭建opengrok用来review android源码,主要有以下步骤 在root用户下(非root用户没试过) 1. 安装java   这里不得不说的是,必须安装...
  • Ubuntu18.04搭建源码搜索引擎Opengrok

    千次阅读 2018-09-11 10:16:29
    2 安装OpenGrok 2.1 安装JAVA运行环境 2.2 安装Web服务器-Tomcat 2.3 安装OpenGrok 2.4 配置OpenGrok 2.5 安装 universal-ctags 2.6 建立源码索引 2.6 更新源码索引 1 OpenGrok介绍 OpenGrok is a fast ...
  • OpenGrok安装配置 - MAC篇 简介 OpenGrok一个快速、便于使用的源代码搜索与对照引擎。它帮助你搜索,对照,定位你的源代码树。它能够明白各种程序文件格式和版本控制历史记录如SCCS,RCS,CVS与Subversion。OpenGrok是...
  • 如何把 opengrok 安装在 windows上

    千次阅读 2013-06-07 09:34:20
    opengrok 是目前最好用的代码索引、浏览工具,比sourceinsight好狠多。 假设已经有一台安装好tomcat服务的机器。此时不需要启动tomcat下载opengrok binary。 http://opengrok.github.io/OpenGrok/把opengrok ...
  • OpenGrok安装配置

    2015-11-30 19:34:00
    ./opengrok/bin/OpenGrok index source_code_absolute_path 配置文件在 /var/opengrok//var/opengrok/etc/configuration.xml 在其中可以进行定制化配置 转载于:...
  • 前言 ...很多做android开发的小伙伴都知道,快速检索代码的利器opengrok,检索代码非常方便,本人之前多次搭建果opengrok,只不过最近终于搞定opengrok+tomcat的ldap认证,所以总结记录下。 准备工作
  • Ubuntu环境下OpenGrok安装及使用

    万次阅读 2013-05-18 17:29:14
    接下来就具体讲解一下OpenGrok安装及使用。 安装Web服务器-Tomcat 第一步: 首先大家应该明白OpenGrok是一个Web系统,因此要共享OpenGrok搜索引擎,需要安装Web服务器。在Ubuntu环境下,推荐使用Tomcat。下载...
  • 1. 下载stable 版本 ...大功告成,OpenGrok安装搭建结束! 以上是我自己学习实践后总结记录的,方便下次使用。 感谢其他朋友的博客参考, http://blog.csdn.net/luzhenrong45/article/details/52734781
  • Ubuntu 18.04安装配置最新opengrok-1.1.2

    千次阅读 2019-02-10 01:39:14
    搜素了一下opengrok的配置,都是使用老版本的例子,本人有使用最新版本的洁癖,因此尝试了一下,记录如下: 1. 下载并编译universal-ctags  如果没有安装git, autoconf,先安装 sudo apt install git autoconf ...
  • OpenGrok在线代码浏览环境搭建

    千次阅读 2018-08-22 22:03:52
    OpenGrok是专门的源码阅读工具在针对特大型源码时,比如 AOSP 和 Chromium,就需要祭出专门的源码阅读工具。 OpenGrok 属于另一类,免费,开源,运行流畅,功能也毫不逊色,该工具环境搭建和使用感觉很简单,但最近...
  • 1.相关工具下载安装 主要有4个工具:Java JDK、opengrok、ctags、tomcat jdk 1.8下载地址: https://mirrors.tuna.tsinghua.edu.cn/AdoptOpenJDK/8/jdk/x64/windows/ opengrok下载地址: ...
  • windows7下安装配置opengrok

    千次阅读 2016-02-04 15:18:27
    opengrok是一个代码查看工具,对于比较大的项目,团队之间一个人搭建好之后其他人可以直接访问使用。
  • opengrok搭建

    千次阅读 2016-11-23 23:36:29
    前序OpenGrok是一个快速,便于使用的源码搜索引擎与对照引擎,它能够帮助我们快速的搜索、定位、对照代码树。一般常用于大型的项目中,比如Android系统源码。 我也是刚来公司后才发现有这个东西的,在此自己也搭建...
  • Opengrok服务搭建

    2017-09-13 22:13:14
    OpenGrok是一个快速,便于使用的源码搜索引擎与对照引擎,在android源代码中搜索一些关键信息,如果使用这个引擎,会十分方便,下面就介绍如何搭建这样一个服务。 1、下载jdk 下载网址:...
  • done Successfully installed opengrok-tools-1.3.13 4.2 部署openGrok 上一步使用pythone安装openGrok的一些工具,我们可以直接使用opengrok的一些工具命令 opengrok-deploy 04-openGrok/dist/lib/source.war 01...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 987
精华内容 394
关键字:

opengrok安装