@@ -10,6 +10,14 @@ buildscript {
1010 isSnapshot = " true" == System . getProperty(" build.snapshot" , " true" )
1111 buildVersionQualifier = System . getProperty(" build.version_qualifier" , " " )
1212 kotlin_version = System . getProperty(" kotlin.version" , " 1.9.25" )
13+ version_tokens = opensearch_version. tokenize(' -' )
14+ opensearch_build = version_tokens[0 ] + ' .0'
15+ if (buildVersionQualifier) {
16+ opensearch_build + = " -${ buildVersionQualifier} "
17+ }
18+ if (isSnapshot) {
19+ opensearch_build + = " -SNAPSHOT"
20+ }
1321 }
1422
1523 repositories {
@@ -68,6 +76,7 @@ apply from: 'build-tools/opensearchplugin-coverage.gradle'
6876apply plugin : ' opensearch.java-agent'
6977
7078configurations {
79+ zipArchive
7180 ktlint {
7281 resolutionStrategy {
7382 force " ch.qos.logback:logback-classic:1.5.16"
@@ -76,6 +85,18 @@ configurations {
7685 }
7786}
7887
88+ def sqlJarDirectory = " $buildDir /dependencies/opensearch-sql-plugin"
89+
90+ task addJarsToClasspath (type : Copy ) {
91+ from(fileTree(dir : sqlJarDirectory)) {
92+ include " opensearch-sql-${ opensearch_build} .jar"
93+ include " ppl-${ opensearch_build} .jar"
94+ include " protocol-${ opensearch_build} .jar"
95+ include " core-${ opensearch_build} .jar"
96+ }
97+ into(" $buildDir /classes" )
98+ }
99+
79100dependencies {
80101 compileOnly " org.opensearch.client:opensearch-rest-high-level-client:${ opensearch_version} "
81102 compileOnly " org.jetbrains.kotlin:kotlin-stdlib:${ kotlin_version} "
@@ -91,16 +112,22 @@ dependencies {
91112 testImplementation " com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
92113 testImplementation " com.cronutils:cron-utils:9.1.6"
93114 testImplementation " commons-validator:commons-validator:1.7"
94- testRuntimeOnly ' org.junit.jupiter:junit-jupiter-engine:5.11.4'
95- implementation ' org.json:json:20240303'
96- implementation " com.google.guava:guava:33.3.0-jre"
97- implementation ' com.google.code.gson:gson:2.10.1'
98- compileOnly ' org.projectlombok:lombok:1.18.38'
99- annotationProcessor ' org.projectlombok:lombok:1.18.38'
115+
116+ implementation fileTree(dir : sqlJarDirectory, include : [" opensearch-sql-${ opensearch_build} .jar" , " ppl-${ opensearch_build} .jar" , " protocol-${ opensearch_build} .jar" , " core-${ opensearch_build} .jar" ])
117+
118+ zipArchive group : ' org.opensearch.plugin' , name :' opensearch-sql-plugin' , version : " ${ opensearch_build} "
100119
101120 ktlint " com.pinterest:ktlint:0.47.1"
102121}
103122
123+ task extractSqlJar (type : Copy ) {
124+ mustRunAfter()
125+ from(zipTree(configurations. zipArchive. find { it. name. startsWith(" opensearch-sql-plugin" ) }))
126+ into sqlJarDirectory
127+ }
128+
129+ tasks. addJarsToClasspath. dependsOn(extractSqlJar)
130+
104131test {
105132 useJUnitPlatform()
106133 testLogging {
@@ -147,7 +174,12 @@ tasks.register('ktlintFormat', JavaExec) {
147174 args " -F" , " src/**/*.kt"
148175}
149176
177+ compileJava {
178+ dependsOn extractSqlJar
179+ }
180+
150181compileKotlin {
182+ dependsOn extractSqlJar
151183 kotlinOptions {
152184 freeCompilerArgs = [' -Xjsr305=strict' ]
153185 jvmTarget = " 21"
0 commit comments