Elasticsearch Plugin Build

By | 2021년 4월 26일
  • 전체 과정 요약
    • elasticsearch 소스 다운로드
    • 소스에서 plugin example 별도 복사
    • build.gradle 수정 및 plugin 빌드
    • elasticsearch 에 빌드한 플러그인 설치
    • 테스트

1. elasticsearch source download

$ mkdir /tmp/work && cd /tmp/work
$ git clone https://github.com/elastic/elasticsearch.git
$ cd elasticsearch && git checkout 7.12

2. copy plugin example – rest-handler

$ cp -r plugins/examples/rest-handler /tmp/work
$ cp -r gradle* /tmp/work/rest-handler/
$ cd /tmp/work

3. edit build.gradle and build

$ vi build.gradle

// import org.elasticsearch.gradle.info.BuildParams 다음줄에 추가
buildscript {
  ext {
    version_es = "7.12.0"
  }

  repositories {
    mavenCentral()
    jcenter()
  }

  dependencies {
    classpath "org.elasticsearch.gradle:build-tools:${version_es}"
  }
}

// apply plugin: 'elasticsearch.java-rest-test' 다음줄에 추가
dependencies {
  yamlRestTestCompile group: "org.apache.logging.log4j", name: "log4j-core", version: "2.11.1"
  javaRestTestCompile  group: "org.apache.logging.log4j", name: "log4j-core", version: "2.11.1"
}
$ ./gradlew test yamlRestTest --warning-mode all
$ ./gradlew test javaRestTest --warning-mode all
$ ./gradlew assemble --warning-mode all

// output to build/distribtions/rest-handler.zip

4. elasticsearch plugin install

elasticsearch 설치 폴더로 이동 (소스 아님)
$ ./bin/elasticsearch-plugin install file:///tmp/work/rest-handler/build/distributions/rest-handler.zip 

5. Test

// start elasticsearch
$ ./bin/elasticsearch
$ curl 127.0.0.1:9200/_cat/example