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

[Backport 2.x] Change js to jar dependency #80

Closed
26 changes: 6 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,14 @@ apply plugin: 'opensearch.testclusters'
apply plugin: 'opensearch.pluginzip'

def sqlJarDirectory = "$buildDir/dependencies/opensearch-sql-plugin"
def jsJarDirectory = "$buildDir/dependencies/opensearch-job-scheduler"
def adJarDirectory = "$buildDir/dependencies/opensearch-anomaly-detection"

configurations {
zipArchive
all {
resolutionStrategy {
force "org.mockito:mockito-core:${versions.mockito}"
force "com.google.guava:guava:32.1.3-jre" // CVE for 31.1
force "com.google.guava:guava:33.0.0-jre" // CVE for 31.1
force("org.eclipse.platform:org.eclipse.core.runtime:3.30.0") // CVE for < 3.29.0, forces JDK17 for spotless
}
}
Expand All @@ -92,11 +91,6 @@ task addJarsToClasspath(type: Copy) {
}
into("$buildDir/classes")

from(fileTree(dir: jsJarDirectory)) {
include "opensearch-job-scheduler-${version}.jar"
}
into("$buildDir/classes")

from(fileTree(dir: adJarDirectory)) {
include "opensearch-anomaly-detection-${version}.jar"
}
Expand All @@ -108,22 +102,22 @@ dependencies {
compileOnly group: 'com.google.code.gson', name: 'gson', version: '2.10.1'
compileOnly "org.apache.logging.log4j:log4j-slf4j-impl:2.22.0"
compileOnly group: 'org.json', name: 'json', version: '20231013'
compileOnly("com.google.guava:guava:32.1.3-jre")
compileOnly("com.google.guava:guava:33.0.0-jre")
compileOnly group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'
compileOnly group: 'org.apache.commons', name: 'commons-text', version: '1.10.0'

// Plugin dependencies
compileOnly group: 'org.opensearch', name:'opensearch-ml-client', version: "${version}"
implementation fileTree(dir: jsJarDirectory, include: ["opensearch-job-scheduler-${version}.jar"])
implementation group: 'org.opensearch', name: 'opensearch-job-scheduler', version: "${version}"
// implementation group: 'org.opensearch', name: 'opensearch-anomaly-detection', version: "${version}"
//TODO change this to jar dependency once ad successfully published jars.
implementation fileTree(dir: adJarDirectory, include: ["opensearch-anomaly-detection-${version}.jar"])
implementation fileTree(dir: sqlJarDirectory, include: ["opensearch-sql-${version}.jar", "ppl-${version}.jar", "protocol-${version}.jar"])
compileOnly "org.opensearch:common-utils:${version}"
compileOnly "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"

// ZipArchive dependencies used for integration tests
zipArchive group: 'org.opensearch.plugin', name:'opensearch-ml-plugin', version: "${version}"
//JS plugin is published to `org/opensearch` instead of `org/opensearch/plugin` under local maven repo: https://mvnrepository.com/artifact/org.opensearch/opensearch-job-scheduler.
zipArchive group: 'org.opensearch', name:'opensearch-job-scheduler', version: "${version}"
zipArchive "org.opensearch.plugin:opensearch-anomaly-detection:${version}"
zipArchive group: 'org.opensearch.plugin', name:'opensearch-sql-plugin', version: "${version}"

Expand All @@ -148,20 +142,13 @@ task extractSqlJar(type: Copy) {
into sqlJarDirectory
}

task extractJsJar(type: Copy) {
mustRunAfter()
from(zipTree(configurations.zipArchive.find { it.name.startsWith("opensearch-job-scheduler")}))
into jsJarDirectory
}

task extractAdJar(type: Copy) {
mustRunAfter()
from(zipTree(configurations.zipArchive.find { it.name.startsWith("opensearch-anomaly-detection")}))
into adJarDirectory
}

tasks.addJarsToClasspath.dependsOn(extractSqlJar)
tasks.addJarsToClasspath.dependsOn(extractJsJar)
tasks.addJarsToClasspath.dependsOn(extractAdJar)
project.tasks.delombok.dependsOn(addJarsToClasspath)
tasks.publishNebulaPublicationToMavenLocal.dependsOn ':generatePomFileForPluginZipPublication'
Expand Down Expand Up @@ -206,7 +193,6 @@ spotless {

compileJava {
dependsOn extractSqlJar
dependsOn extractJsJar
dependsOn extractAdJar
dependsOn delombok
options.compilerArgs.addAll(["-processor", 'lombok.launch.AnnotationProcessorHider$AnnotationProcessor'])
Expand Down Expand Up @@ -364,4 +350,4 @@ task updateVersion {
// Include the required files that needs to be updated with new Version
ant.replaceregexp(file:'build.gradle', match: '"opensearch.version", "\\d.*"', replace: '"opensearch.version", "' + newVersion.tokenize('-')[0] + '-SNAPSHOT"', flags:'g', byline:true)
}
}
}
Loading