Skip to content

Commit 4e33871

Browse files
authored
Migrate the path hierarchy plugin to Elastic 8.x
1 parent 06fc00f commit 4e33871

27 files changed

+1925
-630
lines changed

.github/workflows/build.yml renamed to .github/workflows/build.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build
1+
name: compile-and-test
22

33
on:
44
pull_request:
@@ -13,7 +13,7 @@ jobs:
1313
uses: actions/setup-java@v4
1414
with:
1515
distribution: 'temurin'
16-
java-version: 17
16+
java-version: 21
1717
- name: Setup Gradle
1818
uses: gradle/actions/setup-gradle@v4
1919
- name: Build with Gradle

.github/workflows/release.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: publish
2+
3+
on:
4+
push:
5+
tags: ['v*']
6+
release:
7+
types: [published]
8+
9+
jobs:
10+
build-artifact:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Tag Version Name Extraction
17+
id: version
18+
shell: bash
19+
run: |
20+
if [[ -n "${{ github.event.release.tag_name }}" ]]; then
21+
# Relase Github
22+
TAG_NAME="${{ github.event.release.tag_name }}"
23+
echo "📋 Triggered by GitHub release: $TAG_NAME"
24+
else
25+
# Just a new tag
26+
TAG_NAME=${GITHUB_REF#refs/tags/}
27+
echo "🏷️ Triggered by Git tag: $TAG_NAME"
28+
fi
29+
30+
# Get rid of the 'v', e.g. v8.18.1.0 -> 8.18.1.0
31+
VERSION=${TAG_NAME#v}
32+
echo "version=$VERSION" >> $GITHUB_OUTPUT
33+
34+
- name: Setup Java
35+
uses: actions/setup-java@v4
36+
with:
37+
distribution: 'temurin'
38+
java-version: 21
39+
40+
- name: Setup Gradle
41+
uses: gradle/actions/setup-gradle@v4
42+
43+
- name: Java Compilation
44+
run: ./gradlew -Pplugin_version=${{ steps.version.outputs.version }} clean assemble --no-daemon
45+
46+
- name: Upload Plugin Artifact
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: pathhierarchy-aggregation-${{ steps.version.outputs.version }}
50+
path: build/distributions/*.zip
51+
52+
- name: Attach ZIP to GitHub Release
53+
uses: softprops/action-gh-release@v2
54+
if: github.event.release.tag_name != ''
55+
with:
56+
files: build/distributions/pathhierarchy-aggregation-${{ steps.version.outputs.version }}.zip
57+
tag_name: ${{ github.event.release.tag_name }}
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

LICENSE

Lines changed: 661 additions & 21 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,4 +327,4 @@ GET /calendar/_search?size=0
327327
License
328328
-------
329329

330-
This software is under The MIT License (MIT).
330+
This software is under AGPL (GNU Affero General Public License)

build.gradle

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
/*
2+
Gradle build file for development building, testing, and packaging.
3+
*/
4+
15
buildscript {
26
repositories {
3-
mavenLocal()
47
mavenCentral()
58
}
69

@@ -9,6 +12,11 @@ buildscript {
912
}
1013
}
1114

15+
// the spotless plugin is dedicated to format the code
16+
plugins {
17+
id("com.diffplug.spotless") version "7.0.4"
18+
}
19+
1220
repositories {
1321
mavenLocal()
1422
mavenCentral()
@@ -17,14 +25,11 @@ repositories {
1725
group = 'org.elasticsearch.plugin'
1826
version = "${plugin_version}"
1927

20-
def versions = org.elasticsearch.gradle.VersionProperties.versions
21-
2228
apply plugin: 'java'
2329
apply plugin: 'idea'
2430
apply plugin: 'elasticsearch.esplugin'
2531
apply plugin: 'elasticsearch.yaml-rest-test'
2632

27-
2833
esplugin {
2934
name 'pathhierarchy-aggregation'
3035
description 'Return a path hierarchy aggregation'
@@ -33,17 +38,46 @@ esplugin {
3338
noticeFile = rootProject.file('README.md')
3439
}
3540

36-
41+
def versions = org.elasticsearch.gradle.VersionProperties.versions
3742
dependencies {
3843
implementation "org.elasticsearch:elasticsearch:${es_version}"
3944
yamlRestTestImplementation "org.elasticsearch.test:framework:${es_version}"
45+
yamlRestTestImplementation "org.elasticsearch.test:yaml-rest-runner:${es_version}"
4046
yamlRestTestImplementation "org.apache.logging.log4j:log4j-core:${versions.log4j}"
4147
}
4248

43-
tasks.named("yamlRestTest").configure {
44-
systemProperty 'tests.security.manager', 'false'
49+
// add -Xlint:deprecation to check the Elasticsearch deprecation warning at compile-time
50+
allprojects {
51+
gradle.projectsEvaluated {
52+
tasks.withType(JavaCompile) {
53+
options.compilerArgs << "-Xlint:deprecation"
54+
options.compilerArgs << "-Xlint:unchecked"
55+
}
56+
}
57+
}
58+
59+
// automatic formatting configuration (the same configuration as elasticsearch)
60+
spotless {
61+
java {
62+
importOrderFile('config/elastic.importorder') // import order file as exported from elastic
63+
eclipse().configFile('config/formatterConfig.xml')
64+
trimTrailingWhitespace()
65+
target 'src/**/*.java'
66+
}
4567
}
4668

47-
tasks.named("test").configure {
48-
systemProperty 'tests.security.manager', 'false'
69+
check.dependsOn spotlessCheck
70+
71+
testClusters.configureEach {
72+
// Make sure the ES distribution used for rest tests is the "complete" variant
73+
testDistribution = 'DEFAULT'
74+
75+
// Disable security (avoids annoying warnings/failures with xpack features)
76+
setting 'xpack.security.enabled', 'false'
77+
78+
// Logging levels for debugging: logs are located in build/testclusters/runTask-0/logs/
79+
setting 'logger._root', 'DEBUG'
80+
setting 'logger.org.elasticsearch.plugins', 'DEBUG'
81+
setting 'logger.org.elasticsearch.cluster', 'DEBUG'
82+
setting 'logger.org.elasticsearch.cluster.metadata', 'TRACE'
4983
}

config/elastic.importorder

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#Eclipse configuration for import order for Elasticsearch
2+
0=
3+
1=com
4+
2=org
5+
3=java
6+
4=javax
7+
5=\#

0 commit comments

Comments
 (0)