Skip to content

Commit

Permalink
Updating baseline JDK version to JDK-21 (#1276)
Browse files Browse the repository at this point in the history
* Updating baseline JDK version to JDK-21

Signed-off-by: Kshitij Tandon <[email protected]>

* Updating kotlin version

Signed-off-by: Kshitij Tandon <[email protected]>

* Updating some versions in build.gradle to support JDK 21

Signed-off-by: Kshitij Tandon <[email protected]>

* Updating some more versions and resolving some dependency conflicts

Signed-off-by: Kshitij Tandon <[email protected]>

---------

Signed-off-by: Kshitij Tandon <[email protected]>
  • Loading branch information
tandonks authored Oct 29, 2024
1 parent 4adc99e commit 335bd4c
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: temurin # Temurin is a distribution of adoptium
java-version: 11
java-version: 21
- uses: actions/checkout@v3
- uses: aws-actions/configure-aws-credentials@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/multi-node-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: temurin # Temurin is a distribution of adoptium
java-version: 17
java-version: 21
# index-management
- name: Checkout Branch
uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-and-build-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
fail-fast: false
# This starts three jobs, setting these environment variables uniquely for the different jobs
matrix:
java: [11, 17, 21]
java: [21]
feature: [ism, non-ism]
include:
- feature: ism
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
fail-fast: false
# This starts three jobs, setting these environment variables uniquely for the different jobs
matrix:
java: [11, 17, 21]
java: [21]
os: [windows-latest, macos-latest]
feature: [ism, non-ism]
include:
Expand Down
10 changes: 5 additions & 5 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- [Developer Guide](#developer-guide)
- [Forking and Cloning](#forking-and-cloning)
- [Install Prerequisites](#install-prerequisites)
- [JDK 11](#jdk-11)
- [JDK 21](#jdk-21)
- [Setup](#setup)
- [Build](#build)
- [Building from the command line](#building-from-the-command-line)
Expand All @@ -19,17 +19,17 @@ Fork this repository on GitHub, and clone locally with `git clone`.

### Install Prerequisites

#### JDK 11
#### JDK 21

OpenSearch components build using Java 11 at a minimum. This means you must have a JDK 11 installed with the environment variable `JAVA_HOME` referencing the path to Java home for your JDK 11 installation, e.g. `JAVA_HOME=/usr/lib/jvm/jdk-11`.
OpenSearch components build using Java 21 at a minimum. This means you must have a JDK 21 installed with the environment variable `JAVA_HOME` referencing the path to Java home for your JDK 21 installation, e.g. `JAVA_HOME=/usr/lib/jvm/jdk-21`.

Download Java 11 from [here](https://adoptium.net/releases.html?variant=openjdk11).
Download Java 21 from [here](https://adoptium.net/releases.html?variant=openjdk21).

## Setup

1. Check out this package from version control.
2. Launch Intellij IDEA, choose **Import Project**, and select the `settings.gradle` file in the root of this package.
3. To build from the command line, set `JAVA_HOME` to point to a JDK >= 11 before running `./gradlew`.
3. To build from the command line, set `JAVA_HOME` to point to a JDK >= 21 before running `./gradlew`.
- Unix System
1. `export JAVA_HOME=jdk-install-dir`: Replace `jdk-install-dir` with the JAVA_HOME directory of your system.
2. `export PATH=$JAVA_HOME/bin:$PATH`
Expand Down
19 changes: 11 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ buildscript {
notifications_core_build_download = 'https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/' + opensearch_no_snapshot +
'/latest/linux/x64/tar/builds/opensearch/plugins/opensearch-notifications-core-' + notifications_no_snapshot + '.zip'

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

security_plugin_version = System.getProperty("security.version", opensearch_build)
}
Expand All @@ -79,8 +79,8 @@ buildscript {
classpath "org.opensearch.gradle:build-tools:${opensearch_version}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}"
classpath "org.jetbrains.kotlin:kotlin-allopen:${kotlin_version}"
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.21.0"
classpath "org.jacoco:org.jacoco.agent:0.8.7"
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.6"
classpath "org.jacoco:org.jacoco.agent:0.8.10"
}
}

Expand All @@ -105,6 +105,9 @@ configurations.all {
resolutionStrategy {
force "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"
force "org.jetbrains.kotlin:kotlin-stdlib-common:${kotlin_version}"
force "org.jetbrains.kotlin:kotlin-reflect:${kotlin_version}"
force "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlin_version}"
force "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlin_version}"
force 'junit:junit:4.13.1'
force 'commons-beanutils:commons-beanutils:1.9.4'
force 'com.google.guava:guava:30.0-jre'
Expand Down Expand Up @@ -202,7 +205,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"
implementation "org.jetbrains.kotlin:kotlin-stdlib-common:${kotlin_version}"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlin_version}"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3'
implementation "org.jetbrains:annotations:13.0"
implementation project(path: ":${rootProject.name}-spi", configuration: 'shadow')
implementation "org.opensearch:common-utils:${common_utils_version}"
Expand All @@ -222,7 +225,7 @@ dependencies {
}
}
configurations.ktlint {
resolutionStrategy.force "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22"
resolutionStrategy.force "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10"
}

// https://aws.oss.sonatype.org/content/repositories/snapshots/org/opensearch/plugin/
Expand Down Expand Up @@ -274,11 +277,11 @@ publishing {
tasks.generatePomFileForPluginZipPublication.dependsOn publishNebulaPublicationToMavenLocal

plugins.withId('java') {
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_21
}

plugins.withId('org.jetbrains.kotlin.jvm') {
compileKotlin.kotlinOptions.jvmTarget = compileTestKotlin.kotlinOptions.jvmTarget = JavaVersion.VERSION_11
compileKotlin.kotlinOptions.jvmTarget = compileTestKotlin.kotlinOptions.jvmTarget = JavaVersion.VERSION_21
compileKotlin.dependsOn ktlint
}

Expand Down Expand Up @@ -892,4 +895,4 @@ task updateVersion {
// String tokenization to support -SNAPSHOT
ant.replaceregexp(file: 'build.gradle', match: '"opensearch.version", "\\d.*"', replace: '"opensearch.version", "' + newVersion.tokenize('-')[0] + '-SNAPSHOT"', flags: 'g', byline: true)
}
}
}
4 changes: 4 additions & 0 deletions detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ style:
excludes: ['**/test/**']
FunctionOnlyReturningConstant:
active: false
UseRequire:
active: false
UnusedPrivateProperty:
active: false

complexity:
LargeClass:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package org.opensearch.indexmanagement.indexstatemanagement

import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.SupervisorJob
Expand Down Expand Up @@ -254,6 +255,7 @@ object ManagedIndexRunner :
}
}

@OptIn(DelicateCoroutinesApi::class)
@Suppress("ReturnCount", "ComplexMethod", "LongMethod", "ComplexCondition", "NestedBlockDepth")
private suspend fun runManagedIndexConfig(managedIndexConfig: ManagedIndexConfig, jobContext: JobExecutionContext) {
logger.debug("Run job for index ${managedIndexConfig.index}")
Expand Down Expand Up @@ -640,6 +642,7 @@ object ManagedIndexRunner :
* update metadata in config index, and save metadata in history after update
* this can be called 2 times in one job run, so need to save seqNo & primeTerm
*/
@OptIn(DelicateCoroutinesApi::class)
private suspend fun updateManagedIndexMetaData(
managedIndexMetaData: ManagedIndexMetaData,
lastUpdateResult: UpdateMetadataResult? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package org.opensearch.indexmanagement.indexstatemanagement.step.forcemerge

import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
Expand All @@ -30,6 +31,7 @@ class AttemptCallForceMergeStep(private val action: ForceMergeAction) : Step(nam
private var stepStatus = StepStatus.STARTING
private var info: Map<String, Any>? = null

@OptIn(DelicateCoroutinesApi::class)
@Suppress("TooGenericExceptionCaught", "ComplexMethod")
override suspend fun execute(): AttemptCallForceMergeStep {
val context = this.context ?: return this
Expand Down

0 comments on commit 335bd4c

Please sign in to comment.