Skip to content
This repository has been archived by the owner on Jul 29, 2022. It is now read-only.

Configuration

skogler edited this page Apr 20, 2012 · 19 revisions

Codesearch Configuration File

The main configuration for Codesearch is the codesearch_config.xml file.
This file should be located in the classpath; e.g. in the Apache Tomcat lib/ folder.

The following configurations must be defined:

  • Cache directory
  • Index directory

It is recommended to at least set up the following:

  • 1 repository
  • 1 index job
  • The searcher location

Optional configurations:

  • Available repositories
  • Repository groups
  • Database connection for code analysis

Example configuration:

There should always be an up to date example configuration at resources/codesearch_config.xml in case this doesn't work.

Careful: The names of repositories must NOT contain whitespaces or special characters!
<root>
    <!-- The url of the searcher, used to notify the searcher of changes to the index -->
    <searcher-location>http://127.0.0.1:8080/searcher/</searcher-location>
    <!-- The directory that is used by version control plugins to store checked out repositories -->
    <cache-directory>/var/cache/codesearch/vcs/</cache-directory>
    <!-- The directory where the Lucene search index is stored -->
    <index-directory>/var/index/</index-directory>

    <!-- Blacklists use standard Java regular expressions that apply to the file path -->
    <global-blacklist-filenames>
        <filename>.*\.class</filename>
        <filename>.*\.o</filename>
        <filename>.*\.bin</filename>
    </global-blacklist-filenames>

    <!--
    Indexing jobs can be scheduled using cron expressions. 
    If no cron expressions are defined, the job is executed once at startup.
    
    The clear option specifies whether the index should be cleared before each execution.
    The names of the specified repositories must be separated by spaces.
    -->
    <index-jobs>
        <index-job>
            <repositories>codesearch jdownloader</repositories>
            <cron-expression>0 0 * * * ?</cron-expression>
            <clear>false</clear>
        </index-job>
    </index-jobs>

    <!-- 
    The repositories that can be used for indexing and searching. 
    The names of version control systems must be specified EXACTLY as in the corresponding plugin.
    Groups may be specified to organize a large number of repositories and can be used for 
    searching and in the manual indexing web interface.
    -->
    <repositories>
        <repository>
            <name>codesearch</name>
            <version-control-system>GIT</version-control-system>
            <authentication-data type='none'></authentication-data>
            <url>git://github.com/codesearch-github/codesearch.git</url>
            <code-navigation-enabled>true</code-navigation-enabled>
            <groups>java git</groups>
        </repository>
        <repository>
            <name>jdownloader</name>
            <version-control-system>SVN</version-control-system>
            <authentication-data type='none'></authentication-data>
            <url>svn://svn.jdownloader.org/jdownloader</url>
            <code-navigation-enabled>true</code-navigation-enabled>
            <groups>java svn</groups>
        </repository>
    </repositories>
</root>       

Repository authentication

There is the possibility to specify login data to access a repository.

<authentication-data type='basic'>
    <username>exampleuser</username>
    <password>examplepassword</examplepassword>
</authentication-data>

or

<authentication-data type='ssh'>
    <file-path>/var/usr/codesearch/id_rsa.pub</file-path>
</authentication-data>

WARNING: Check if the corresponding plugin supports the specified type of authentication.

Database connection

Codesearch uses JNDI database connections provided by the application server. A HowTo for Tomcat is at this page: http://wiki.apache.org/tomcat/UsingDataSources

The name of the provided resource must be jdbc/codesearch

Example Tomcat context.xml file

<?xml version='1.0' encoding='utf-8'?>
<Context>
    <Resource 
        name="jdbc/codesearch" 
        auth="Container" 
        type="javax.sql.DataSource"
        username="codesearch" 
        password="" 
        url="jdbc:mysql://localhost:3306/codesearch"
        driverClassName="com.mysql.jdbc.Driver"
        />
</Context>