elasticsearch. tutorials

Getting Started with Source Code

By Lukáš Vlček | 03 Jul 2010

The following is a step-by-step tutorial which shows how to download, setup and explore ElasticSearch source code, especially if you do not have prior experience with Gradle.

elasticsearch (ES) source code build and dependency management is handled by Gradle. If you haven’t been using Gradle so far, do not worry, it is very easy to utilize provided gradle scripts.

The best way to explore ES source code is via IntelliJ IDEA because IDEA settings for ES project are included in repository (.idea folder). If you do not have IDEA license you can download community edition.

  1. Download the ES source code into new home folder:
    git clone git://github.com/elasticsearch/elasticsearch.git
  2. Run:
    gradlew
    found in the ES home folder. (Depending on your OS you might want to run gradlew.bat.) This will download gradle and setup local gradle repository with all dependencies.
  3. Run:
    gradlew test
    to download test dependencies (TestNG, Hamcrest) – these are needed if you want to run tests from IDEA.
  4. Start IDEA and open ES project
  5. After the project is opened you need to set GRADLE_REPOSITORY value.
    Either the IDEA will open a small window and ask you to provide the value or you can configure this in settings: (Ctrl+Alt+S), search for Path Variables and edit GRADLE_REPOSITORY value. The gradle repository can be found in .gradle/cache folder in your home folder (e.g. the GRADLE_REPOSITORY value would be /home/lukas/.gradle/cache).
    It is important to set this value correctly for the first time. If you change the value later then it may not propagated correctly into all IDEA config files (this happend to me and I had to do new fresh clone of ES source code and setup the value again).
  6. You are done. Now you should have the classpath setup correctly and you should be able to build, test and run ES from within IDEA (you can do this from command line as well).
blog comments powered by Disqus
 
Fork me on GitHub