Skip to content

Commit e5fa9e2

Browse files
committed
Monitor, Trigger, Alert Models and Dependencies
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
1 parent 11132d2 commit e5fa9e2

8 files changed

Lines changed: 1259 additions & 0 deletions

File tree

alerting/build.gradle

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,24 @@ import org.opensearch.gradle.test.RestIntegTestTask
2121
import org.opensearch.gradle.testclusters.OpenSearchCluster
2222
import 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+
2442
apply plugin: 'java'
2543
apply plugin: 'idea'
2644
apply 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"
146165
def bwcOpenSearchVersion = bwcVersionShort + "-SNAPSHOT"
147166
def 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+
149180
dependencies {
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+
183242
javadoc.enabled = false // turn off javadoc as it barfs on Kotlin code
184243
licenseHeaders.enabled = true
185244
dependencyLicenses.enabled = false
@@ -655,3 +714,11 @@ def waitForClusterSetup(OpenSearchCluster cluster, Boolean securityEnabled) {
655714
}
656715

657716
apply from: '../build-tools/pkgbuild.gradle'
717+
718+
//compileJava {
719+
// dependsOn addJarsToClasspath
720+
//}
721+
//
722+
//compileKotlin {
723+
// dependsOn addJarsToClasspath
724+
//}

core/build.gradle

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,45 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6+
buildscript {
7+
ext {
8+
opensearch_group = "org.opensearch"
9+
opensearch_version = System.getProperty("opensearch.version", "3.1.0-SNAPSHOT")
10+
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
11+
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
12+
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+
}
21+
}
22+
}
23+
624
apply plugin: 'java'
725
apply plugin: 'opensearch.java-rest-test'
826
apply plugin: 'org.jetbrains.kotlin.jvm'
927
apply plugin: 'jacoco'
1028

29+
configurations {
30+
zipArchive
31+
}
32+
33+
def sqlJarDirectory = "$buildDir/dependencies/opensearch-sql-plugin"
34+
35+
task addJarsToClasspath(type: Copy) {
36+
from(fileTree(dir: sqlJarDirectory)) {
37+
include "opensearch-sql-${opensearch_build}.jar"
38+
include "ppl-${opensearch_build}.jar"
39+
include "protocol-${opensearch_build}.jar"
40+
include "core-${opensearch_build}.jar"
41+
}
42+
into("$buildDir/classes")
43+
}
44+
1145
dependencies {
1246
compileOnly "org.opensearch:opensearch:${opensearch_version}"
1347
implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"
@@ -17,8 +51,44 @@ dependencies {
1751
api "org.opensearch.client:opensearch-rest-client:${opensearch_version}"
1852
api "org.opensearch:common-utils:${common_utils_version}@jar"
1953
implementation 'commons-validator:commons-validator:1.7'
54+
implementation 'org.json:json:20240303'
55+
56+
api fileTree(dir: sqlJarDirectory, include: ["opensearch-sql-thin-${opensearch_build}.jar", "ppl-${opensearch_build}.jar", "protocol-${opensearch_build}.jar", "core-${opensearch_build}.jar"])
57+
58+
zipArchive group: 'org.opensearch.plugin', name:'opensearch-sql-plugin', version: "${opensearch_build}"
2059

2160
testImplementation "org.opensearch.test:framework:${opensearch_version}"
2261
testImplementation "org.jetbrains.kotlin:kotlin-test:${kotlin_version}"
2362
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:${kotlin_version}"
2463
}
64+
65+
task extractSqlJar(type: Copy) {
66+
mustRunAfter()
67+
from(zipTree(configurations.zipArchive.find { it.name.startsWith("opensearch-sql-plugin") }))
68+
into sqlJarDirectory
69+
}
70+
71+
task extractSqlClass(type: Copy, dependsOn: [extractSqlJar]) {
72+
from zipTree("${sqlJarDirectory}/opensearch-sql-${opensearch_build}.jar")
73+
into("$buildDir/opensearch-sql")
74+
include 'org/opensearch/sql/**'
75+
}
76+
77+
task replaceSqlJar(type: Jar, dependsOn: [extractSqlClass]) {
78+
from("$buildDir/opensearch-sql")
79+
archiveFileName = "opensearch-sql-thin-${opensearch_build}.jar"
80+
destinationDirectory = file(sqlJarDirectory)
81+
doLast {
82+
file("${sqlJarDirectory}/opensearch-sql-${opensearch_build}.jar").delete()
83+
}
84+
}
85+
86+
tasks.addJarsToClasspath.dependsOn(replaceSqlJar)
87+
88+
compileJava {
89+
dependsOn addJarsToClasspath
90+
}
91+
92+
compileKotlin {
93+
dependsOn addJarsToClasspath
94+
}

0 commit comments

Comments
 (0)