66buildscript {
77
88 ext {
9- opensearch_version = System . getProperty(" opensearch.version" , " 1.3.0-SNAPSHOT" )
9+ opensearch_version = System . getProperty(" opensearch.version" , " 2.0.0-alpha1-SNAPSHOT" )
10+ isSnapshot = " true" == System . getProperty(" build.snapshot" , " true" )
11+ buildVersionQualifier = System . getProperty(" build.version_qualifier" , " alpha1" )
12+
13+ // 2.0.0-alpha1-SNAPSHOT -> 2.0.0.0-alpha1-SNAPSHOT
14+ version_tokens = opensearch_version. tokenize(' -' )
15+ opensearch_build = version_tokens[0 ] + ' .0'
16+ if (buildVersionQualifier) {
17+ opensearch_build + = " -${ buildVersionQualifier} "
18+ }
19+ if (isSnapshot) {
20+ opensearch_build + = " -SNAPSHOT"
21+ }
1022 }
1123
1224 // Used to resolve build file dependencies
@@ -26,11 +38,13 @@ buildscript {
2638plugins {
2739 id ' java'
2840 id ' nebula.ospackage' version " 8.3.0"
29- id ' com.github.spotbugs' version ' 4.6 .0'
41+ id ' com.github.spotbugs' version ' 5.0 .0'
3042 id ' jacoco'
3143 id ' com.diffplug.spotless' version ' 5.11.0'
3244 id ' checkstyle'
45+ id ' org.ajoberstar.grgit' version ' 5.0.0'
3346 id ' org.gradle.test-retry' version ' 1.3.1'
47+
3448}
3549
3650spotbugsMain {
@@ -49,8 +63,6 @@ spotbugsTest {
4963}
5064
5165ext {
52- isSnapshot = " true" == System . getProperty(" build.snapshot" , " true" )
53-
5466 // The RCA branch that will be built. Default branch is main.
5567 rcaProjectRepo = System . getProperty(" performance-analyzer-rca.repo" , " https://github.com/opensearch-project/performance-analyzer-rca.git" )
5668 rcaProjectBranch = System . getProperty(" performance-analyzer-rca.branch" , " main" )
6476
6577allprojects {
6678 group = " org.opensearch"
67- version = opensearch_version - ' -SNAPSHOT' + ' .0'
68- if (isSnapshot) {
69- version + = " -SNAPSHOT"
70- }
79+ version = opensearch_build
7180}
7281
7382apply plugin : ' opensearch.opensearchplugin'
@@ -78,7 +87,7 @@ noticeFile = rootProject.file('NOTICE.txt')
7887spotless {
7988 java {
8089 licenseHeaderFile(file(' license-header' ))
81- googleJavaFormat(). aosp()
90+ googleJavaFormat(' 1.12.0 ' ). aosp()
8291 importOrder()
8392 removeUnusedImports()
8493 trimTrailingWhitespace()
@@ -112,22 +121,14 @@ opensearchplugin {
112121 classname ' org.opensearch.performanceanalyzer.PerformanceAnalyzerPlugin'
113122}
114123
115- sourceCompatibility = 1.8
116- targetCompatibility = 1.8
124+ sourceCompatibility = JavaVersion . VERSION_11
125+ targetCompatibility = JavaVersion . VERSION_11
117126
118127compileJava {
119128 dependsOn spotlessApply
120- JavaVersion targetVersion = JavaVersion . toVersion(targetCompatibility);
121- if (targetVersion. isJava9Compatible()) {
122- options. compilerArgs + = [" --add-exports" , " jdk.attach/sun.tools.attach=ALL-UNNAMED" ]
123- }
124129}
125130
126131javadoc {
127- JavaVersion targetVersion = JavaVersion . toVersion(targetCompatibility);
128- if (targetVersion. isJava9Compatible()) {
129- options. addStringOption(" -add-exports" , " jdk.attach/sun.tools.attach=ALL-UNNAMED" )
130- }
131132}
132133
133134project. afterEvaluate {
@@ -159,7 +160,7 @@ tasks.withType(JavaCompile) {
159160}
160161
161162jacoco {
162- toolVersion = " 0.8.5 "
163+ toolVersion = " 0.8.7 "
163164}
164165
165166jacocoTestReport {
@@ -212,7 +213,7 @@ checkstyleTest.enabled = false
212213
213214dependencies {
214215 if (JavaVersion . current() <= JavaVersion . VERSION_1_8 ) {
215- compile files(" ${ System.properties['java.home']} /../lib/tools.jar" )
216+ implementation files(" ${ System.properties['java.home']} /../lib/tools.jar" )
216217 }
217218
218219 def jacksonVersion = " 2.12.6"
@@ -233,88 +234,92 @@ dependencies {
233234 force " com.fasterxml.jackson.core:jackson-core:${ jacksonVersion} "
234235 force " com.fasterxml.jackson.core:jackson-databind:${ jacksonVersion} "
235236 force " com.fasterxml.jackson.module:jackson-module-paranamer:${ jacksonVersion} "
237+ force " com.fasterxml.jackson.dataformat:jackson-dataformat-smile:${ jacksonVersion} "
238+ force " com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${ jacksonVersion} "
239+ force " com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:${ jacksonVersion} "
240+ force " org.apache.commons:commons-lang3:3.12.0"
236241 }
237242 }
238243
239- compile (' com.google.guava:guava:30.1-jre' ) {
244+ implementation (' com.google.guava:guava:30.1-jre' ) {
240245 force = ' true'
241246 }
242- compile ' org.jooq:jooq:3.10.8'
243- compile ' org.apache.commons:commons-lang3:3.9'
244- compile ' org.bouncycastle:bcprov-jdk15on:1.70'
245- compile ' org.bouncycastle:bcpkix-jdk15on:1.70'
246- compile " org.opensearch:performanceanalyzer-rca:${ version} "
247- compile " com.fasterxml.jackson.core:jackson-annotations:${ jacksonVersion} "
248- compile " com.fasterxml.jackson.core:jackson-databind:${ jacksonVersion} "
249- compile " com.fasterxml.jackson.module:jackson-module-paranamer:${ jacksonVersion} "
250- compile (group : ' org.apache.logging.log4j' , name : ' log4j-api' , version : ' 2.17.1' )
251- compile (group : ' org.apache.logging.log4j' , name : ' log4j-core' , version : ' 2.17.1' )
252- compile (group : ' com.google.errorprone' , name : ' error_prone_annotations' , version : ' 2.9.0' ) {
247+ implementation ' org.jooq:jooq:3.10.8'
248+ implementation ' org.apache.commons:commons-lang3:3.9'
249+ implementation ' org.bouncycastle:bcprov-jdk15on:1.70'
250+ implementation ' org.bouncycastle:bcpkix-jdk15on:1.70'
251+ implementation " org.opensearch:performanceanalyzer-rca:${ version} "
252+ implementation " com.fasterxml.jackson.core:jackson-annotations:${ jacksonVersion} "
253+ implementation " com.fasterxml.jackson.core:jackson-databind:${ jacksonVersion} "
254+ implementation " com.fasterxml.jackson.module:jackson-module-paranamer:${ jacksonVersion} "
255+ implementation (group : ' org.apache.logging.log4j' , name : ' log4j-api' , version : ' 2.17.1' )
256+ implementation (group : ' org.apache.logging.log4j' , name : ' log4j-core' , version : ' 2.17.1' )
257+ implementation (group : ' com.google.errorprone' , name : ' error_prone_annotations' , version : ' 2.9.0' ) {
253258 force = ' true'
254259 }
255- compile (group : ' com.google.protobuf' , name :' protobuf-java' , version : ' 3.19.2' ) {
260+ implementation (group : ' com.google.protobuf' , name :' protobuf-java' , version : ' 3.19.2' ) {
256261 force = ' true'
257262 }
258- compile (" io.netty:netty-buffer:${ nettyVersion} " ) {
263+ implementation (" io.netty:netty-buffer:${ nettyVersion} " ) {
259264 force = ' true'
260265 }
261- compile (" io.netty:netty-codec:${ nettyVersion} " ) {
266+ implementation (" io.netty:netty-codec:${ nettyVersion} " ) {
262267 force = ' true'
263268 }
264- compile (" io.netty:netty-codec-http:${ nettyVersion} " ) {
269+ implementation (" io.netty:netty-codec-http:${ nettyVersion} " ) {
265270 force = ' true'
266271 }
267- compile (" io.netty:netty-common:${ nettyVersion} " ) {
272+ implementation (" io.netty:netty-common:${ nettyVersion} " ) {
268273 force = ' true'
269274 }
270- compile (" io.netty:netty-handler:${ nettyVersion} " ) {
275+ implementation (" io.netty:netty-handler:${ nettyVersion} " ) {
271276 force = ' true'
272277 }
273- compile (" io.netty:netty-resolver:${ nettyVersion} " ) {
278+ implementation (" io.netty:netty-resolver:${ nettyVersion} " ) {
274279 force = ' true'
275280 }
276- compile (" io.netty:netty-transport:${ nettyVersion} " ) {
281+ implementation (" io.netty:netty-transport:${ nettyVersion} " ) {
277282 force = ' true'
278283 }
279- compile (" io.netty:netty-codec-http2:${ nettyVersion} " ) {
284+ implementation (" io.netty:netty-codec-http2:${ nettyVersion} " ) {
280285 force = ' true'
281286 }
282- compile (" io.netty:netty-codec-socks:${ nettyVersion} " ) {
287+ implementation (" io.netty:netty-codec-socks:${ nettyVersion} " ) {
283288 force = ' true'
284289 }
285- compile (" io.netty:netty-handler-proxy:${ nettyVersion} " ) {
290+ implementation (" io.netty:netty-handler-proxy:${ nettyVersion} " ) {
286291 force = ' true'
287292 }
288293
289294
290295 // JDK9+ has to run powermock 2+. https://github.com/powermock/powermock/issues/888
291- testCompile group : ' org.powermock' , name : ' powermock-api-mockito2' , version : ' 2.0.0'
292- testCompile (group : ' org.powermock' , name : ' powermock-module-junit4' , version : ' 2.0.0' ) {
296+ testImplementation group : ' org.powermock' , name : ' powermock-api-mockito2' , version : ' 2.0.0'
297+ testImplementation (group : ' org.powermock' , name : ' powermock-module-junit4' , version : ' 2.0.0' ) {
293298 exclude(group : ' org.hamcrest' , module : ' hamcrest-core' )
294299 }
295- testCompile (group : ' org.mockito' , name : ' mockito-core' , version : ' 2.23.0' ) {
300+ testImplementation (group : ' org.mockito' , name : ' mockito-core' , version : ' 2.23.0' ) {
296301 force = ' true'
297302 }
298303 // Dependency to mock final classes.
299304 testImplementation group : ' org.mockito' , name : ' mockito-inline' , version : ' 2.13.0'
300- testCompile group : ' org.powermock' , name : ' powermock-core' , version : ' 2.0.0'
301- testCompile group : ' org.powermock' , name : ' powermock-api-support' , version : ' 2.0.0'
302- testCompile (group : ' org.powermock' , name : ' powermock-module-junit4-common' , version : ' 2.0.0' ) {
305+ testImplementation group : ' org.powermock' , name : ' powermock-core' , version : ' 2.0.0'
306+ testImplementation group : ' org.powermock' , name : ' powermock-api-support' , version : ' 2.0.0'
307+ testImplementation (group : ' org.powermock' , name : ' powermock-module-junit4-common' , version : ' 2.0.0' ) {
303308 exclude(group : ' org.hamcrest' , module : ' hamcrest-core' )
304309 }
305- testCompile group : ' org.javassist' , name : ' javassist' , version : ' 3.24.0-GA'
306- testCompile group : ' org.powermock' , name : ' powermock-reflect' , version : ' 2.0.0'
310+ testImplementation group : ' org.javassist' , name : ' javassist' , version : ' 3.24.0-GA'
311+ testImplementation group : ' org.powermock' , name : ' powermock-reflect' , version : ' 2.0.0'
307312 // minimum byte-buddy version to be compatible with mockito-core 2.23.0 is 1.9.7+. https://github.com/mockito/mockito/issues/1606
308- testCompile (group : ' net.bytebuddy' , name : ' byte-buddy' , version : ' 1.9.7' ) {
313+ testImplementation (group : ' net.bytebuddy' , name : ' byte-buddy' , version : ' 1.9.7' ) {
309314 force = ' true'
310315 }
311- testCompile (group : ' net.bytebuddy' , name : ' byte-buddy-agent' , version : ' 1.9.7' ) {
316+ testImplementation (group : ' net.bytebuddy' , name : ' byte-buddy-agent' , version : ' 1.9.7' ) {
312317 force = ' true'
313318 }
314- testCompile (group : ' org.objenesis' , name : ' objenesis' , version : ' 3.0.1' ) {
319+ testImplementation (group : ' org.objenesis' , name : ' objenesis' , version : ' 3.0.1' ) {
315320 force = ' true'
316321 }
317- testCompile group : ' com.google.code.gson' , name : ' gson' , version : ' 2.8.9'
322+ testImplementation group : ' com.google.code.gson' , name : ' gson' , version : ' 2.8.9'
318323}
319324
320325dependencyLicenses {
@@ -332,7 +337,7 @@ gradle.startParameter.excludedTaskNames += [ "forbiddenApisMain",
332337 " testingConventions" ]
333338
334339import java.util.concurrent.Callable
335- import org.ajoberstar.gradle.git.tasks.GitClone
340+ import org.ajoberstar.grgit.Grgit
336341import org.opensearch.gradle.test.RestIntegTestTask
337342import org.opensearch.gradle.testclusters.StandaloneRestIntegTestTask
338343
@@ -347,16 +352,21 @@ static def propEnabled(property) {
347352 * cloneRcaGitRepo clones the performance-analyzer-rca repo if the -Dtests.enableIT=true flag is passed
348353 * to the Gradle JVM
349354 */
350- task cloneRcaGitRepo (type : GitClone ) {
355+ task cloneRcaGitRepo () {
351356 def destination = file(rcaProjectDir)
352- uri = rcaProjectRepo
353- branch = rcaProjectBranch
354- destinationPath = destination
355- bare = false
356- enabled = cloneRcaProject && ! destination. exists() // to clone only once
357-
357+ def uri = rcaProjectRepo
358+ def branch = rcaProjectBranch
358359 doFirst {
359- logger. info(" Cloning performance-analyzer-rca into ${ rcaProjectDir} from ${ rcaProjectRepo} #${ rcaProjectBranch} " )
360+ println " Cloning performance-analyzer-rca into ${ rcaProjectDir} from ${ rcaProjectRepo} #${ rcaProjectBranch} "
361+ }
362+ doLast {
363+ if (destination. exists() && destination. isDirectory()) { // If directory exists, use this instead.
364+ def grgit = Grgit . open(dir : destination. toString())
365+ } else { // Otherwise pull it from git.
366+ def grgit = Grgit . clone(dir : destination. toString(), uri : uri)
367+ grgit. fetch(remote : ' origin' )
368+ grgit. checkout(branch : branch)
369+ }
360370 }
361371}
362372
@@ -370,11 +380,21 @@ task buildRca() {
370380 doLast {
371381 exec {
372382 workingDir(" $rcaProjectDir " )
373- commandLine ' ./gradlew' , ' build' , ' -x' , ' test' , " -Dopensearch.version=${ opensearch_version} " , " -Dbuild.snapshot=${ isSnapshot} "
383+ if (buildVersionQualifier == null || buildVersionQualifier == ' ' || buildVersionQualifier == ' null' ) {
384+ commandLine ' ./gradlew' , ' build' , ' -x' , ' test' , " -Dopensearch.version=${ opensearch_version} " , " -Dbuild.snapshot=${ isSnapshot} "
385+ }
386+ else {
387+ commandLine ' ./gradlew' , ' build' , ' -x' , ' test' , " -Dopensearch.version=${ opensearch_version} " , " -Dbuild.snapshot=${ isSnapshot} " , " -Dbuild.version_qualifier=${ buildVersionQualifier} "
388+ }
374389 }
375390 exec {
376391 workingDir(" $rcaProjectDir " )
377- commandLine ' ./gradlew' , ' publishToMavenLocal' , " -Dopensearch.version=${ opensearch_version} " , " -Dbuild.snapshot=${ isSnapshot} "
392+ if (buildVersionQualifier == null || buildVersionQualifier == ' ' || buildVersionQualifier == ' null' ) {
393+ commandLine ' ./gradlew' , ' publishToMavenLocal' , " -Dopensearch.version=${ opensearch_version} " , " -Dbuild.snapshot=${ isSnapshot} "
394+ }
395+ else {
396+ commandLine ' ./gradlew' , ' publishToMavenLocal' , " -Dopensearch.version=${ opensearch_version} " , " -Dbuild.snapshot=${ isSnapshot} " , " -Dbuild.version_qualifier=${ buildVersionQualifier} "
397+ }
378398 }
379399 exec {
380400 def licenseDir = " $projectDir /licenses"
@@ -401,6 +421,14 @@ task unpackRca(type: Copy) {
401421 }
402422}
403423
424+ tasks. withType(Test ) {
425+ jvmArgs(' --add-opens=java.base/sun.security.jca=ALL-UNNAMED' )
426+ jvmArgs(' --add-opens=java.base/java.util.concurrent=ALL-UNNAMED' )
427+ jvmArgs(' --add-opens=java.base/java.io=ALL-UNNAMED' )
428+ jvmArgs(' --add-opens=java.base/java.nio.file=ALL-UNNAMED' )
429+ }
430+
431+
404432bundlePlugin {
405433 dependsOn ' unpackRca'
406434 from(" $rcaArtifactsDir /pa_config" ) {
@@ -522,7 +550,7 @@ String bwcFilePath = "src/test/resources/org/opensearch/performanceanalyzer/bwc/
522550 testClusters {
523551 " ${ baseName} $i " {
524552 testDistribution = " ARCHIVE"
525- versions = [" 7.10.2" ," 1.3.0-SNAPSHOT " ]
553+ versions = [" 7.10.2" , opensearch_version ]
526554 numberOfNodes = 3
527555 plugin(provider(new Callable<RegularFile > (){
528556 @Override
@@ -662,7 +690,7 @@ afterEvaluate {
662690 ospackage {
663691 packageName = " opensearch-performance-analyzer"
664692 release = isSnapshot ? " 0.1" : ' 1'
665- version = " ${ project.version} " - " -SNAPSHOT "
693+ version = " ${ project.version} "
666694
667695 into ' /usr/share/opensearch/plugins'
668696 from(zipTree(bundlePlugin. archivePath)) {
0 commit comments