Skip to content

Commit 06fc00f

Browse files
authored
Merge pull request #34 from opendatasoft/automate-builds-first-step
Add some scripts to facilitate plugin generation for new ES versions
2 parents 548b0da + ad912cd commit 06fc00f

File tree

12 files changed

+140
-27
lines changed

12 files changed

+140
-27
lines changed

.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ES_VERSION=7.17.28
2+
PLUGIN_VERSION=7.17.28.0
3+
JAVA_COMPILER_VERSION=17
4+
GRADLE_VERSION=8.10.2

.github/workflows/build.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout sources
11+
uses: actions/checkout@v4
12+
- name: Setup Java
13+
uses: actions/setup-java@v4
14+
with:
15+
distribution: 'temurin'
16+
java-version: 17
17+
- name: Setup Gradle
18+
uses: gradle/actions/setup-gradle@v4
19+
- name: Build with Gradle
20+
run: ./gradlew build

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ Built with Java 17 and Gradle 8.10.2.
2525

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

28+
29+
Upgrade the plugin
30+
------------
31+
32+
In order to upgrade the plugin, one can simply run for example `./prepare-version.sh 7.17.28`. It will:
33+
- fetch dependencies versions form Elasticsearch internals
34+
- upgrade the configuration files
35+
36+
You can then run `./build.sh` that will build the plugin in a docker container using gradle.
37+
If successful, the plugin will be available in `./build/distributions/` (under the name `pathhierarchy-aggregation-7.17.28.0.zip` in this example).
38+
39+
40+
2841
Development Environment Setup
2942
------------
3043

build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ repositories {
1717
group = 'org.elasticsearch.plugin'
1818
version = "${plugin_version}"
1919

20+
def versions = org.elasticsearch.gradle.VersionProperties.versions
21+
2022
apply plugin: 'java'
2123
apply plugin: 'idea'
2224
apply plugin: 'elasticsearch.esplugin'
@@ -35,7 +37,7 @@ esplugin {
3537
dependencies {
3638
implementation "org.elasticsearch:elasticsearch:${es_version}"
3739
yamlRestTestImplementation "org.elasticsearch.test:framework:${es_version}"
38-
yamlRestTestImplementation "org.apache.logging.log4j:log4j-core:2.17.1"
40+
yamlRestTestImplementation "org.apache.logging.log4j:log4j-core:${versions.log4j}"
3941
}
4042

4143
tasks.named("yamlRestTest").configure {

build.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
# helper script that runs the build script inside a gradle based docker container
4+
5+
source .env
6+
7+
echo "GRADLE_VERSION ${GRADLE_VERSION}"
8+
9+
docker run --rm \
10+
-v .:/opt/gen \
11+
-w /opt/gen \
12+
-u gradle \
13+
gradle:${GRADLE_VERSION} ./gradlew build

docker-compose.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ services:
77
context: .
88
dockerfile: docker/Dockerfile
99
target: elasticsearch-plugin-debug
10+
args:
11+
ES_VERSION: ${ES_VERSION}
12+
PLUGIN_VERSION: ${PLUGIN_VERSION}
13+
PLUGIN_FILENAME: pathhierarchy-aggregation-${PLUGIN_VERSION}.zip
1014
environment:
1115
- discovery.type=single-node
1216
# NO DEBUG

docker/Dockerfile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
FROM docker.elastic.co/elasticsearch/elasticsearch:7.17.28 AS elasticsearch-plugin-debug
1+
ARG ES_VERSION
2+
ARG PLUGIN_FILENAME
23

3-
COPY /build/distributions/pathhierarchy-aggregation-7.17.28.0.zip /tmp/pathhierarchy-aggregation-7.17.28.0.zip
4-
RUN ./bin/elasticsearch-plugin install file:/tmp/pathhierarchy-aggregation-7.17.28.0.zip
4+
FROM docker.elastic.co/elasticsearch/elasticsearch:${ES_VERSION} AS elasticsearch-plugin-debug
5+
6+
COPY build/distributions/${PLUGIN_FILENAME} /tmp/${PLUGIN_FILENAME}
7+
8+
# mandatory because docker ARG is scoped to stage (forgotten after the FROM scope above...!)
9+
ARG PLUGIN_FILENAME
10+
# madantory because ARGS cannot be used inside RUN shell
11+
ENV PLUGIN_FILENAME=${PLUGIN_FILENAME}
12+
RUN ./bin/elasticsearch-plugin install --batch file:/tmp/${PLUGIN_FILENAME}

gradle/wrapper/gradle-wrapper.jar

-17.6 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
44
networkTimeout=10000
5+
validateDistributionUrl=true
56
zipStoreBase=GRADLE_USER_HOME
67
zipStorePath=wrapper/dists

gradlew

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -83,10 +85,9 @@ done
8385
# This is normally unused
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
86-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
87-
88-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
88+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
90+
' "$PWD" ) || exit
9091

9192
# Use the maximum available, or set MAX_FD != -1 to use that value.
9293
MAX_FD=maximum
@@ -133,26 +134,29 @@ location of your Java installation."
133134
fi
134135
else
135136
JAVACMD=java
136-
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137+
if ! command -v java >/dev/null 2>&1
138+
then
139+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137140
138141
Please set the JAVA_HOME variable in your environment to match the
139142
location of your Java installation."
143+
fi
140144
fi
141145

142146
# Increase the maximum file descriptors if we can.
143147
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144148
case $MAX_FD in #(
145149
max*)
146150
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147-
# shellcheck disable=SC3045
151+
# shellcheck disable=SC2039,SC3045
148152
MAX_FD=$( ulimit -H -n ) ||
149153
warn "Could not query maximum file descriptor limit"
150154
esac
151155
case $MAX_FD in #(
152156
'' | soft) :;; #(
153157
*)
154158
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155-
# shellcheck disable=SC3045
159+
# shellcheck disable=SC2039,SC3045
156160
ulimit -n "$MAX_FD" ||
157161
warn "Could not set maximum file descriptor limit to $MAX_FD"
158162
esac
@@ -197,11 +201,15 @@ if "$cygwin" || "$msys" ; then
197201
done
198202
fi
199203

200-
# Collect all arguments for the java command;
201-
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
202-
# shell script including quotes and variable substitutions, so put them in
203-
# double quotes to make sure that they get re-expanded; and
204-
# * put everything else in single quotes, so that it's not re-expanded.
204+
205+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
206+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
207+
208+
# Collect all arguments for the java command:
209+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
210+
# and any embedded shellness will be escaped.
211+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
212+
# treated as '${Hostname}' itself on the command line.
205213

206214
set -- \
207215
"-Dorg.gradle.appname=$APP_BASE_NAME" \

0 commit comments

Comments
 (0)