From 77a7d0391f6c9bfdbd9c6ce85332819bcf47fda7 Mon Sep 17 00:00:00 2001 From: Marc Handalian Date: Thu, 25 Sep 2025 16:24:06 -0700 Subject: [PATCH 1/2] Update installedPlugins in run.gradle to fetch plugins from maven. This change allows us to install plugins not shipped with core with gradlew run. It supports simply specifying the plugin name or adding a specific version. Example: ./gradlew run -PinstalledPlugins['opensearch-job-scheduler'] or ./gradlew run -PinstalledPlugins['opensearch-job-scheduler:3.2.x.x] Signed-off-by: Marc Handalian --- DEVELOPER_GUIDE.md | 15 +++++++++++++-- gradle/run.gradle | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index 2d7125b241af7..a5233f4ba00a8 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -76,9 +76,9 @@ Fork [opensearch-project/OpenSearch](https://github.com/opensearch-project/OpenS #### JDK -OpenSearch recommends building with the [Temurin/Adoptium](https://adoptium.net/temurin/releases/) distribution. JDK 11 is the minimum supported, and JDK-24 is the newest supported. You must have a supported JDK installed with the environment variable `JAVA_HOME` referencing the path to Java home for your JDK installation, e.g. `JAVA_HOME=/usr/lib/jvm/jdk-21`. +OpenSearch recommends building with the [Temurin/Adoptium](https://adoptium.net/temurin/releases/) distribution. JDK 11 is the minimum supported, and JDK-24 is the newest supported. You must have a supported JDK installed with the environment variable `JAVA_HOME` referencing the path to Java home for your JDK installation, e.g. `JAVA_HOME=/usr/lib/jvm/jdk-21`. -Download Java 11 from [here](https://adoptium.net/releases.html?variant=openjdk11). +Download Java 11 from [here](https://adoptium.net/releases.html?variant=openjdk11). In addition, certain backward compatibility tests check out and compile the previous major version of OpenSearch, and therefore require installing [JDK 11](https://adoptium.net/temurin/releases/?version=11) and [JDK 17](https://adoptium.net/temurin/releases/?version=17) and setting the `JAVA11_HOME` and `JAVA17_HOME` environment variables. More to that, since 8.10 release, Gradle has deprecated the usage of the any JDKs below JDK-16. For smooth development experience, the recommendation is to install at least [JDK 17](https://adoptium.net/temurin/releases/?version=17) or [JDK 21](https://adoptium.net/temurin/releases/?version=21). If you still want to build with JDK-11 only, please add `-Dorg.gradle.warning.mode=none` when invoking any Gradle build task from command line, for example: @@ -178,6 +178,17 @@ Run OpenSearch using `gradlew run`. ./gradlew run -PinstalledPlugins="['plugin1', 'plugin2']" ``` +External plugins may also be fetched and installed from maven snapshots: + +```bash +./gradlew run -PinstalledPlugins="['opensearch-job-scheduler', 'opensearch-sql-plugin']" +``` + +You can also specify a plugin version to pull to test a released version: +```bash +./gradlew run -PinstalledPlugins="['opensearch-job-scheduler:3.3.x.x']" +``` + That will build OpenSearch and start it, writing its log above Gradle's status message. We log a lot of stuff on startup, specifically these lines tell you that OpenSearch is ready. ``` diff --git a/gradle/run.gradle b/gradle/run.gradle index ac58d74acd6b0..27f57f4f67472 100644 --- a/gradle/run.gradle +++ b/gradle/run.gradle @@ -28,6 +28,7 @@ * under the License. */ import org.opensearch.gradle.testclusters.RunTask +import org.opensearch.gradle.VersionProperties apply plugin: 'opensearch.testclusters' @@ -41,8 +42,39 @@ testClusters { if (numNodes > 1) numberOfNodes = numNodes if (findProperty("installedPlugins")) { installedPlugins = Eval.me(installedPlugins) + + def resolveMavenPlugin = { coords -> + def config = project.configurations.detachedConfiguration( + project.dependencies.create('org.opensearch.plugin:' + coords) + ) + config.resolutionStrategy.cacheChangingModulesFor 0, 'seconds' + plugin(project.layout.file(project.provider { config.singleFile })) + } + for (String p : installedPlugins) { - plugin('plugins:'.concat(p)) + // check if its a local plugin first + if (project.findProject(':plugins:' + p) != null) { + plugin('plugins:' + p) + } else { + // attempt to fetch it from maven + project.repositories.mavenLocal() + project.repositories { + maven { + name = 'OpenSearch Snapshots' + url = 'https://central.sonatype.com/repository/maven-snapshots/' + } + } + if (p.contains(':')) { + // Maven coordinates with version specified + String coords = p.contains('@') ? p : (p + '@zip') + resolveMavenPlugin(coords) + } else { + // Not found locally, try Maven with current OS version + 0 + String version = VersionProperties.getOpenSearch().replace('-SNAPSHOT', '.0-SNAPSHOT') + String coords = p + ':' + version + '@zip' + resolveMavenPlugin(coords) + } + } if (p.equals("arrow-flight-rpc")) { // Add system properties for Netty configuration systemProperty 'io.netty.allocator.numDirectArenas', '1' From 16271a4bf09a491beace4be3e7439e9a6787e66b Mon Sep 17 00:00:00 2001 From: Marc Handalian Date: Fri, 26 Sep 2025 10:27:07 -0700 Subject: [PATCH 2/2] Add support for third party plugins Signed-off-by: Marc Handalian --- DEVELOPER_GUIDE.md | 8 +++++++- gradle/run.gradle | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index a5233f4ba00a8..847bdd80eeaa1 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -184,11 +184,17 @@ External plugins may also be fetched and installed from maven snapshots: ./gradlew run -PinstalledPlugins="['opensearch-job-scheduler', 'opensearch-sql-plugin']" ``` -You can also specify a plugin version to pull to test a released version: +You can specify a plugin version to pull to test a specific version in the org.opensearch.plugin groupId: ```bash ./gradlew run -PinstalledPlugins="['opensearch-job-scheduler:3.3.x.x']" ``` +or install with fully qualified maven coordinates: +```bash +./gradlew run -PinstalledPlugins="['com.example:my-cool-plugin:3.3.x.x']" +``` + + That will build OpenSearch and start it, writing its log above Gradle's status message. We log a lot of stuff on startup, specifically these lines tell you that OpenSearch is ready. ``` diff --git a/gradle/run.gradle b/gradle/run.gradle index 27f57f4f67472..3d89bdb10fefa 100644 --- a/gradle/run.gradle +++ b/gradle/run.gradle @@ -44,8 +44,14 @@ testClusters { installedPlugins = Eval.me(installedPlugins) def resolveMavenPlugin = { coords -> + // Add default groupId if not fully qualified (less than 2 colons) + String[] parts = coords.split(':') + if (parts.length == 2 && parts[0].contains('.')) { + throw new IllegalArgumentException("version is required if groupdId is specified '${coords}' Use format: groupId:artifactId:version") + } + String fullCoords = parts.length < 3 ? 'org.opensearch.plugin:' + coords : coords def config = project.configurations.detachedConfiguration( - project.dependencies.create('org.opensearch.plugin:' + coords) + project.dependencies.create(fullCoords) ) config.resolutionStrategy.cacheChangingModulesFor 0, 'seconds' plugin(project.layout.file(project.provider { config.singleFile }))