@@ -21,6 +21,24 @@ import org.opensearch.gradle.test.RestIntegTestTask
2121import org.opensearch.gradle.testclusters.OpenSearchCluster
2222import org.opensearch.gradle.testclusters.StandaloneRestIntegTestTask
2323
24+ buildscript {
25+ ext {
26+ opensearch_group = " org.opensearch"
27+ opensearch_version = System . getProperty(" opensearch.version" , " 3.1.0-SNAPSHOT" )
28+ isSnapshot = " true" == System . getProperty(" build.snapshot" , " true" )
29+ buildVersionQualifier = System . getProperty(" build.version_qualifier" , " " )
30+ kotlin_version = System . getProperty(" kotlin.version" , " 1.9.25" )
31+ version_tokens = opensearch_version. tokenize(' -' )
32+ opensearch_build = version_tokens[0 ] + ' .0'
33+ if (buildVersionQualifier) {
34+ opensearch_build + = " -${ buildVersionQualifier} "
35+ }
36+ if (isSnapshot) {
37+ opensearch_build + = " -SNAPSHOT"
38+ }
39+ }
40+ }
41+
2442apply plugin : ' java'
2543apply plugin : ' idea'
2644apply plugin : ' org.jetbrains.kotlin.jvm'
@@ -81,6 +99,7 @@ publishing {
8199 }
82100
83101 repositories {
102+ mavenLocal()
84103 maven {
85104 name = " Snapshots"
86105 url = " https://aws.oss.sonatype.org/content/repositories/snapshots"
@@ -146,6 +165,18 @@ def bwcVersion = bwcVersionShort + ".0"
146165def bwcOpenSearchVersion = bwcVersionShort + " -SNAPSHOT"
147166def bwcPluginVersion = bwcVersion + " -SNAPSHOT"
148167
168+ def sqlJarDirectory = " $buildDir /dependencies/opensearch-sql-plugin"
169+
170+ task addJarsToClasspath (type : Copy ) {
171+ from(fileTree(dir : sqlJarDirectory)) {
172+ include " opensearch-sql-${ opensearch_build} .jar"
173+ include " ppl-${ opensearch_build} .jar"
174+ include " protocol-${ opensearch_build} .jar"
175+ include " core-${ opensearch_build} .jar"
176+ }
177+ into(" $buildDir /classes" )
178+ }
179+
149180dependencies {
150181 // Needed for integ tests
151182 zipArchive group : ' org.opensearch.plugin' , name :' opensearch-notifications-core' , version : " ${ opensearch_build} "
@@ -167,6 +198,11 @@ dependencies {
167198 implementation " org.jetbrains.kotlin:kotlin-stdlib-common:${ kotlin_version} "
168199 implementation " org.jetbrains:annotations:13.0"
169200
201+ // SQL/PPL plugin dependencies
202+ implementation ' org.json:json:20240303'
203+ // implementation fileTree(dir: sqlJarDirectory, include: ["opensearch-sql-thin-${opensearch_build}.jar", "ppl-${opensearch_build}.jar", "protocol-${opensearch_build}.jar", "core-${opensearch_build}.jar"])
204+ // zipArchive group: 'org.opensearch.plugin', name:'opensearch-sql-plugin', version: "${opensearch_build}"
205+
170206 api project(" :alerting-core" )
171207 implementation " com.github.seancfoley:ipaddress:5.4.1"
172208 implementation project(path : " :alerting-spi" , configuration : ' shadow' )
@@ -180,6 +216,29 @@ dependencies {
180216 testImplementation " org.opensearch.plugin:lang-mustache-client:${ opensearch_version} "
181217}
182218
219+ task extractSqlJar (type : Copy ) {
220+ mustRunAfter()
221+ from(zipTree(configurations. zipArchive. find { it. name. startsWith(" opensearch-sql-plugin" ) }))
222+ into sqlJarDirectory
223+ }
224+
225+ task extractSqlClass (type : Copy , dependsOn : [extractSqlJar]) {
226+ from zipTree(" ${ sqlJarDirectory} /opensearch-sql-${ opensearch_build} .jar" )
227+ into(" $buildDir /opensearch-sql" )
228+ include ' org/opensearch/sql/**'
229+ }
230+
231+ task replaceSqlJar (type : Jar , dependsOn : [extractSqlClass]) {
232+ from(" $buildDir /opensearch-sql" )
233+ archiveFileName = " opensearch-sql-thin-${ opensearch_build} .jar"
234+ destinationDirectory = file(sqlJarDirectory)
235+ doLast {
236+ file(" ${ sqlJarDirectory} /opensearch-sql-${ opensearch_build} .jar" ). delete()
237+ }
238+ }
239+
240+ tasks. addJarsToClasspath. dependsOn(replaceSqlJar)
241+
183242javadoc. enabled = false // turn off javadoc as it barfs on Kotlin code
184243licenseHeaders. enabled = true
185244dependencyLicenses. enabled = false
@@ -655,3 +714,11 @@ def waitForClusterSetup(OpenSearchCluster cluster, Boolean securityEnabled) {
655714}
656715
657716apply from : ' ../build-tools/pkgbuild.gradle'
717+
718+ // compileJava {
719+ // dependsOn addJarsToClasspath
720+ // }
721+ //
722+ // compileKotlin {
723+ // dependsOn addJarsToClasspath
724+ // }
0 commit comments