Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ES_VERSION=7.17.28
PLUGIN_VERSION=7.17.28.0
JAVA_COMPILER_VERSION=17
GRADLE_VERSION=8.10.2
20 changes: 20 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Build

on:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build with Gradle
run: ./gradlew build
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ Built with Java 17 and Gradle 8.10.2.

The first 3 digits of plugin version is Elasticsearch versioning. The last digit is used for plugin versioning under an elasticsearch version.


Upgrade the plugin
------------

In order to upgrade the plugin, one can simply run for example `./prepare-version.sh 7.17.28`. It will:
- fetch dependencies versions form Elasticsearch internals
- upgrade the configuration files

You can then run `./build.sh` that will build the plugin in a docker container using gradle.
If successful, the plugin will be available in `./build/distributions/` (under the name `pathhierarchy-aggregation-7.17.28.0.zip` in this example).



Development Environment Setup
------------

Expand Down
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ repositories {
group = 'org.elasticsearch.plugin'
version = "${plugin_version}"

def versions = org.elasticsearch.gradle.VersionProperties.versions

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'elasticsearch.esplugin'
Expand All @@ -35,7 +37,7 @@ esplugin {
dependencies {
implementation "org.elasticsearch:elasticsearch:${es_version}"
yamlRestTestImplementation "org.elasticsearch.test:framework:${es_version}"
yamlRestTestImplementation "org.apache.logging.log4j:log4j-core:2.17.1"
yamlRestTestImplementation "org.apache.logging.log4j:log4j-core:${versions.log4j}"
}

tasks.named("yamlRestTest").configure {
Expand Down
13 changes: 13 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

# helper script that runs the build script inside a gradle based docker container

source .env

echo "GRADLE_VERSION ${GRADLE_VERSION}"

docker run --rm \
-v .:/opt/gen \
-w /opt/gen \
-u gradle \
gradle:${GRADLE_VERSION} ./gradlew build
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ services:
context: .
dockerfile: docker/Dockerfile
target: elasticsearch-plugin-debug
args:
ES_VERSION: ${ES_VERSION}
PLUGIN_VERSION: ${PLUGIN_VERSION}
PLUGIN_FILENAME: pathhierarchy-aggregation-${PLUGIN_VERSION}.zip
environment:
- discovery.type=single-node
# NO DEBUG
Expand Down
14 changes: 11 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
FROM docker.elastic.co/elasticsearch/elasticsearch:7.17.28 AS elasticsearch-plugin-debug
ARG ES_VERSION
ARG PLUGIN_FILENAME

COPY /build/distributions/pathhierarchy-aggregation-7.17.28.0.zip /tmp/pathhierarchy-aggregation-7.17.28.0.zip
RUN ./bin/elasticsearch-plugin install file:/tmp/pathhierarchy-aggregation-7.17.28.0.zip
FROM docker.elastic.co/elasticsearch/elasticsearch:${ES_VERSION} AS elasticsearch-plugin-debug

COPY build/distributions/${PLUGIN_FILENAME} /tmp/${PLUGIN_FILENAME}

# mandatory because docker ARG is scoped to stage (forgotten after the FROM scope above...!)
ARG PLUGIN_FILENAME
# madantory because ARGS cannot be used inside RUN shell
ENV PLUGIN_FILENAME=${PLUGIN_FILENAME}
RUN ./bin/elasticsearch-plugin install --batch file:/tmp/${PLUGIN_FILENAME}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
1 change: 1 addition & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
34 changes: 21 additions & 13 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 12 additions & 10 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions prepare-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash

# Helper script to prepare a version of the plugin based on a specific elasticsearch version
#
# given the elasticsearch version as argument, it generates the needed configuration file to build the plugin

[ -z "$1" ] && {
echo "1st argument should be the targeted elasticsearch version"
exit 1
}

ES_VERSION="$1"

# retrieve version information from ES repository
GRADLE_VERSION=$(curl -s https://raw.githubusercontent.com/elastic/elasticsearch/refs/tags/v${ES_VERSION}/build-tools-internal/src/main/resources/minimumGradleVersion)
JAVA_COMPILER_VERSION=$(curl -s https://raw.githubusercontent.com/elastic/elasticsearch/refs/tags/v${ES_VERSION}/build-tools-internal/src/main/resources/minimumCompilerVersion)
JAVA_RUNTIME_VERSION=$(curl -s https://raw.githubusercontent.com/elastic/elasticsearch/refs/tags/v${ES_VERSION}/build-tools-internal/src/main/resources/minimumRuntimeVersion)

PLUGIN_VERSION="${ES_VERSION}.0"

echo "GRADLE_VERSION ${GRADLE_VERSION}"
echo "JAVA_COMPILER_VERSION ${JAVA_COMPILER_VERSION}"
echo "ES_VERSION ${ES_VERSION}"
echo "PLUGIN_VERSION ${PLUGIN_VERSION}"

echo "es_version = ${ES_VERSION}
plugin_version = ${PLUGIN_VERSION}" > gradle.properties

echo "ES_VERSION=${ES_VERSION}
PLUGIN_VERSION=${PLUGIN_VERSION}
JAVA_COMPILER_VERSION=${JAVA_COMPILER_VERSION}
GRADLE_VERSION=${GRADLE_VERSION}" > .env

docker run --rm \
-v .:/opt/gen \
-w /opt/gen \
-u gradle \
gradle:"${GRADLE_VERSION}" /usr/bin/gradle wrapper --gradle-version "${GRADLE_VERSION}" --distribution-type bin
Loading