Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support s3 using repackage #482

Merged
merged 27 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 87 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ buildscript {
opensearch_build += "-SNAPSHOT"
}
opensearch_no_snapshot = opensearch_build.replace("-SNAPSHOT","")

kotlin_version = System.getProperty("kotlin.version", "1.8.21")
}

Expand Down Expand Up @@ -83,9 +83,13 @@ java {
def sqlJarDirectory = "$buildDir/dependencies/opensearch-sql-plugin"
def jsJarDirectory = "$buildDir/dependencies/opensearch-job-scheduler"
def adJarDirectory = "$buildDir/dependencies/opensearch-time-series-analytics"
def sparkDir = "$buildDir/dependencies/spark"

configurations {
zipArchive
spark {
transitive = false
}
secureIntegTestPluginArchive
all {
resolutionStrategy {
Expand Down Expand Up @@ -113,11 +117,20 @@ task addJarsToClasspath(type: Copy) {
include "opensearch-time-series-analytics-${opensearch_build}.jar"
}
into("$buildDir/classes")

// spark jar
from(fileTree(dir: sparkDir)) {
include("*.jar")
}
into("$buildDir/classes")
}


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neat: remove the new added blank lines


dependencies {
// 3P dependencies
compileOnly group: 'com.google.code.gson', name: 'gson', version: '2.10.1'

compileOnly "org.apache.logging.log4j:log4j-slf4j-impl:2.23.1"
compileOnly group: 'org.json', name: 'json', version: '20240303'
compileOnly("com.google.guava:guava:33.2.1-jre")
Expand All @@ -126,11 +139,25 @@ dependencies {
compileOnly("com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}")
compileOnly("com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}")

spark 'org.apache.spark:spark-sql-api_2.13:3.5.4'
spark 'org.apache.spark:spark-core_2.13:3.5.4'
spark group: 'org.apache.spark', name: 'spark-common-utils_2.13', version: '3.5.4'

implementation 'org.scala-lang:scala-library:2.13.8'
implementation group: 'org.antlr', name: 'antlr4-runtime', version: '4.9.3'
implementation("org.json4s:json4s-ast_2.13:3.7.0-M11")
implementation("org.json4s:json4s-core_2.13:3.7.0-M11")
implementation("org.json4s:json4s-jackson_2.13:3.7.0-M11")
implementation 'com.fasterxml.jackson.module:jackson-module-scala_3:2.18.2'
implementation group: 'org.scala-lang', name: 'scala3-library_3', version: '3.7.0-RC1-bin-20250119-bd699fc-NIGHTLY'
implementation("com.thoughtworks.paranamer:paranamer:2.8")

// Plugin dependencies
compileOnly group: 'org.opensearch', name:'opensearch-ml-client', version: "${opensearch_build}"
implementation fileTree(dir: jsJarDirectory, include: ["opensearch-job-scheduler-${opensearch_build}.jar"])
implementation fileTree(dir: adJarDirectory, include: ["opensearch-anomaly-detection-${opensearch_build}.jar"])
implementation fileTree(dir: sqlJarDirectory, include: ["opensearch-sql-${opensearch_build}.jar", "ppl-${opensearch_build}.jar", "protocol-${opensearch_build}.jar"])
implementation fileTree(dir: sparkDir, include: ["spark*.jar"])
compileOnly "org.opensearch:common-utils:${opensearch_build}"
compileOnly "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"
compileOnly "org.opensearch:opensearch-job-scheduler-spi:${opensearch_build}"
Expand Down Expand Up @@ -161,6 +188,64 @@ dependencies {
testImplementation "commons-validator:commons-validator:1.8.0"
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.2'
}
task addSparkJar(type: Copy) {
mustRunAfter()
from(configurations.spark)
into sparkDir

doLast {
def jarA = file("$sparkDir/spark-sql-api_2.13-3.5.4.jar")
def jarB = file("$sparkDir/spark-core_2.13-3.5.4.jar")
def jarC = file("$sparkDir/spark-common-utils_2.13-3.5.4.jar")

// 3a. Extract jar A to manipulate it
def jarAContents = file("$buildDir/tmp/JarAContents")
delete(jarAContents)
jarAContents.mkdirs()
copy {
from zipTree(jarA)
into jarAContents
}
// Remove the unwanted directory from jar A
delete file("${jarAContents}/org/apache/spark/unused")

// Re-compress jar A
ant.zip(destfile: jarA, baseDir: jarAContents)

// 3b. Repeat for jar B
def jarBContents = file("$buildDir/tmp/JarBContents")
delete(jarBContents)
jarBContents.mkdirs()
copy {
from zipTree(jarB)
into jarBContents
}
// Remove the unwanted directory from jar B
delete file("${jarBContents}/org/apache/spark/unused")

// Re-compress jar B
ant.zip(destfile: jarB, baseDir: jarBContents)

def jarCContents = file("$buildDir/tmp/JarBContents")
delete(jarCContents)
jarCContents.mkdirs()
copy {
from zipTree(jarC)
into jarCContents
}
// Remove the unwanted directory from jar C
delete file("${jarCContents}/org/apache/spark/unused")
delete file("${jarCContents}/org/apache/spark/SparkDriverExecutionException.class")
delete file("${jarCContents}/org/apache/spark/SparkUserAppException.class")
delete file("${jarCContents}/org/apache/spark/SparkUserAppException\$.class")
delete file("${jarCContents}/org/apache/spark/SparkUserAppException*class")


// Re-compress jar C
ant.zip(destfile: jarC, baseDir: jarCContents)
}
}


task extractSqlJar(type: Copy) {
mustRunAfter()
Expand All @@ -183,6 +268,7 @@ task extractAdJar(type: Copy) {
tasks.addJarsToClasspath.dependsOn(extractSqlJar)
tasks.addJarsToClasspath.dependsOn(extractJsJar)
tasks.addJarsToClasspath.dependsOn(extractAdJar)
tasks.addJarsToClasspath.dependsOn(addSparkJar)
project.tasks.delombok.dependsOn(addJarsToClasspath)
tasks.publishNebulaPublicationToMavenLocal.dependsOn ':generatePomFileForPluginZipPublication'
tasks.validateNebulaPom.dependsOn ':generatePomFileForPluginZipPublication'
Expand Down Expand Up @@ -341,7 +427,6 @@ task integTest(type: RestIntegTestTask) {
tasks.named("check").configure { dependsOn(integTest) }

integTest {

dependsOn "bundlePlugin"
systemProperty 'tests.security.manager', 'false'
systemProperty 'java.io.tmpdir', opensearch_tmp_dir.absolutePath
Expand Down Expand Up @@ -400,7 +485,6 @@ integTest {
jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005'
}
}

// Set up integration test clusters, installs all zipArchive dependencies and this plugin
testClusters.integTest {
testDistribution = "ARCHIVE"
Expand Down
Loading
Loading