Skip to content

Commit

Permalink
Migrate to Java 21
Browse files Browse the repository at this point in the history
  • Loading branch information
ravinperera00 committed Nov 9, 2024
1 parent d1b1e18 commit a5656ea
Show file tree
Hide file tree
Showing 19 changed files with 96 additions and 77 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-ballerina-to-openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
if: github.repository_owner == 'ballerina-platform'
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: 17.0.7
distribution: 'temurin'
java-version: 21.0.3
- name: Change to Timestamped Version
run: |
startTime=$(TZ="Asia/Kolkata" date +'%Y%m%d-%H%M00')
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build-timestamped-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
if: github.repository_owner == 'ballerina-platform'
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: 17.0.7
distribution: 'temurin'
java-version: 21.0.3
- name: Change to Timestamped Version
run: |
startTime=$(TZ="Asia/Kolkata" date +'%Y%m%d-%H%M00')
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/central-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
if: github.repository_owner == 'ballerina-platform'
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: 17.0.7
distribution: 'temurin'
java-version: 21.0.3
- name: Grant execute permission for gradlew
run: chmod +x gradlew

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish-ballerina-to-openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: 17.0.7
distribution: 'temurin'
java-version: 21.0.3
- name: Set version env variable
run: echo "VERSION=$((grep -w "ballerinaToOpenAPIVersion" | cut -d= -f2) < gradle.properties | rev | cut --complement -d- -f1 | rev)" >> $GITHUB_ENV
- name: Pre release dependency version update
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: 17.0.7
distribution: 'temurin'
java-version: 21.0.3
- name: Check for Ballerina to OpenAPI release
run: |
BAL_TO_OPENAPI_VERSION=$(grep -w "ballerinaToOpenAPIVersion" gradle.properties | cut -d= -f2)
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: 17.0.7
distribution: 'temurin'
java-version: 21.0.3
- name: Build with Gradle
env:
packageUser: ${{ github.actor }}
Expand All @@ -32,11 +32,11 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: 17.0.7
distribution: 'temurin'
java-version: 21.0.3
- name: Build with Gradle
env:
packageUser: ${{ github.actor }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ For more information on the supported operations, go to [Using the OpenAPI Tools

### Setting Up the Prerequisites

1. OpenJDK 11 ([Adopt OpenJDK](https://adoptopenjdk.net/) or any other OpenJDK distribution)
1. OpenJDK 21 ([Adopt OpenJDK](https://adoptopenjdk.net/) or any other OpenJDK distribution)

>**Info:** You can also use [Oracle JDK](https://www.oracle.com/java/technologies/javase-downloads.html). Set the JAVA_HOME environment variable to the pathname of the directory into which you installed JDK.
Expand Down
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
plugins {
id "base"
id 'maven-publish'
id "com.github.spotbugs" version "5.0.14"
id "com.github.johnrengelman.shadow" version "8.1.1"
id "de.undercouch.download" version "5.4.0"
id "net.researchgate.release" version "2.8.0"
id "com.github.spotbugs" version "${spotbugsPluginVersion}"
id "com.github.johnrengelman.shadow" version "${shadowJarPluginVersion}"
id "de.undercouch.download" version "${downloadPluginVersion}"
id "net.researchgate.release" version "${releasePluginVersion}"
id 'org.javamodularity.moduleplugin' version '1.7.0' apply false
id "org.sonarqube" version "4.0.0.2929"
}
Expand Down Expand Up @@ -54,7 +54,7 @@ ext.stdlibTaskVersion = project.stdlibTaskVersion
ext.stdlibFileVersion = project.stdlibFileVersion
ext.stdlibHttpVersion = project.stdlibHttpVersion
ext.stdlibUrlVersion = project.stdlibUrlVersion
ext.stdlibXmldataVersion = project.stdlibXmldataVersion
ext.stdlibDataXmldataVersion = project.stdlibDataXmldataVersion
ext.stdlibGraphqlVersion = project.stdlibGraphqlVersion
ext.stdlibGrpcVersion = project.stdlibGrpcVersion
ext.stdlibWebsubVersion = project.stdlibWebsubVersion
Expand Down Expand Up @@ -129,7 +129,7 @@ subprojects {
ballerinaStdLibs "io.ballerina.stdlib:oauth2-ballerina:${stdlibOAuth2Version}"
ballerinaStdLibs "io.ballerina.stdlib:uuid-ballerina:${stdlibUuidVersion}"
ballerinaStdLibs "io.ballerina.stdlib:url-ballerina:${stdlibUrlVersion}"
ballerinaStdLibs "io.ballerina.lib:data.xmldata-ballerina:${stdlibXmldataVersion}"
ballerinaStdLibs "io.ballerina.lib:data.xmldata-ballerina:${stdlibDataXmldataVersion}"
ballerinaStdLibs "io.ballerina.stdlib:observe-ballerina:${observeVersion}"
ballerinaStdLibs "io.ballerina:observe-ballerina:${observeInternalVersion}"
ballerinaStdLibs "io.ballerina.stdlib:graphql-ballerina:${stdlibGraphqlVersion}"
Expand Down
65 changes: 35 additions & 30 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,65 +4,70 @@ version=2.1.1-SNAPSHOT

ballerinaToOpenAPIVersion=2.1.1-SNAPSHOT

spotbugsPluginVersion=6.0.18
shadowJarPluginVersion=8.1.1
downloadPluginVersion=5.4.0
releasePluginVersion=2.8.0

# Client Native Version
clientNativeVersion=1.0.1-SNAPSHOT
# Mark this as false to skip publishing the client native artifacts
clientNativePublish=false

#dependency
ballerinaLangVersion=2201.11.0-20241008-112400-81975006
ballerinaLangVersion=2201.10.0-20241025-103700-5c9e6a27
testngVersion=7.6.1
slf4jVersion=1.7.30
org.gradle.jvmargs=-Xmx4096M -Dfile.encoding=UTF-8
commonsLang3Version=3.14.0
commonsIoVersion=2.15.1
netLingalaZip4jVersion=2.8.0
commonsLang3Version=3.17.0
commonsIoVersion=2.17.0
netLingalaZip4jVersion=2.11.5
jacocoVersion=0.8.10
swaggerCoreVersion=2.2.22
swaggerParserVersion=2.1.22
puppycrawlCheckstyleVersion = 10.12.1
commonsCodecVersion=1.16.0
commonsCodecVersion=1.17.1

# Stdlib Level 01
stdlibIoVersion=1.6.1
stdlibRegexVersion=1.4.3
stdlibTimeVersion=2.4.0
stdlibUrlVersion=2.4.0
stdlibXmldataVersion=1.0.0
stdlibIoVersion=1.6.2-20240928-084100-656404f
stdlibRegexVersion=1.4.4-20241108-130200-fcd3fce
stdlibTimeVersion=2.5.1-20240930-120200-e59222b
stdlibUrlVersion=2.4.1-20240930-120200-b7fb9e1
stdlibDataXmldataVersion=1.0.1-20241007-160500-205fdda

# Stdlib Level 02
stdlibConstraintVersion=1.5.0
stdlibCryptoVersion=2.7.2
stdlibLogVersion=2.10.0
stdlibOsVersion=1.8.0
stdlibTaskVersion=2.5.0
stdlibConstraintVersion=1.5.1-20240930-123400-5ecd396
stdlibCryptoVersion=2.7.3-20240930-132000-5ecc9ab
stdlibLogVersion=2.10.1-20240930-154200-5ab2aa4
stdlibOsVersion=1.8.1-20241001-120600-dd1626e
stdlibTaskVersion=2.5.1-20241002-145700-5bdb843

# Stdlib Level 03
stdlibCacheVersion=3.8.0
stdlibFileVersion=1.10.0
stdlibMimeVersion=2.10.0
stdlibUuidVersion=1.8.0
stdlibCacheVersion=3.8.1-20241007-154900-63f4403
stdlibFileVersion=1.10.1-20241007-160900-03f7b64
stdlibMimeVersion=2.10.1-20241009-141200-8b6c9f0
stdlibUuidVersion=1.8.1-20241009-134600-a05012b

# Stdlib Level 04
stdlibAuthVersion=2.12.0
stdlibDataJsonDataVersion=0.3.0-20241105-101100-661d11f
stdlibJwtVersion=2.13.0
stdlibOAuth2Version=2.12.0
stdlibAuthVersion=2.12.1-20241010-130800-733dbef
stdlibDataJsonDataVersion=0.3.0-20241011-150300-07653f7
stdlibJwtVersion=2.13.1-20241010-123600-5ea6a94
stdlibOAuth2Version=2.12.1-20241029-084800-d7ba9e5

# Stdlib Level 05
stdlibHttpVersion=2.13.0-20241106-120000-d375c3b
stdlibHttpVersion=2.13.0-20241029-110700-30ed05b

# Stdlib Level 06
stdlibGrpcVersion=1.12.0
stdlibWebsocketVersion=2.12.0
stdlibWebsubVersion=2.12.0
stdlibGrpcVersion=1.12.2-20241106-150300-3da09ef
stdlibWebsocketVersion=2.12.1-20241104-132000-aba9ccb
stdlibWebsubVersion=2.12.1-20241106-150600-36752c6

# Stdlib Level 07
stdlibGraphqlVersion=1.14.0
stdlibGraphqlVersion=1.14.1-20241106-150100-7a32b9e

# Ballerinax Observer
observeVersion=1.3.0
observeInternalVersion=1.3.0
observeVersion=1.3.1-20241007-161000-645452d
observeInternalVersion=1.3.1-20241015-172900-cdc3cb3

# Enabled publishing insecure checksums, due to fail to publish to maven central
# Refer https://github.com/gradle/gradle/issues/11308
Expand Down
9 changes: 6 additions & 3 deletions gradle/javaProject.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ dependencies {
checkstyle "com.puppycrawl.tools:checkstyle:${project.puppycrawlCheckstyleVersion}"
}

sourceCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21

def excludePattern = '**/module-info.java'
tasks.withType(Checkstyle) {
Expand Down Expand Up @@ -140,9 +140,12 @@ checkstyle {
}

spotbugsMain {
def classLoader = plugins["com.github.spotbugs"].class.classLoader
def SpotBugsConfidence = classLoader.findLoadedClass("com.github.spotbugs.snom.Confidence")
def SpotBugsEffort = classLoader.findLoadedClass("com.github.spotbugs.snom.Effort")
effort = SpotBugsEffort.MAX
reportLevel = SpotBugsConfidence.LOW
ignoreFailures = true
effort = "max"
reportLevel = "low"
reportsDir = file("$project.buildDir/reports/spotbugs")
def excludeFile = file("${rootDir}/spotbugs-exclude.xml")
if (excludeFile.exists()) {
Expand Down
2 changes: 1 addition & 1 deletion module-ballerina-openapi/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[package]
org= "ballerina"
name= "openapi"
version= "@toml.version@"
version= "2.1.1"
4 changes: 2 additions & 2 deletions module-ballerina-openapi/CompilerPlugin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id = "openapi-tools"
class = "io.ballerina.openapi.validator.OpenAPIValidatorPlugin"

[[dependency]]
path = "../openapi-validator/build/libs/openapi-validator-@project.version@.jar"
path = "../openapi-validator/build/libs/openapi-validator-2.1.1-SNAPSHOT.jar"
groupId = "ballerina"
artifactId = "openapi"
version = "@project.version@."
version = "2.1.1-SNAPSHOT"
2 changes: 1 addition & 1 deletion module-ballerina-openapi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jar {

def packageName = "openapi"
def packageOrg = "ballerina"
def platform = "java17"
def platform = "java21"
def tomlVersion = stripBallerinaExtensionVersion("${project.version}")
def ballerinaConfigFilePlaceHolder = new File("${project.rootDir}/config/resources/Ballerina.toml")
def ballerinaCompileConfigFilePlaceHolder = new File("${project.rootDir}/config/resources/CompilerPlugin.toml")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ private boolean clientNativeDependencyAlreadyExist(String version, ToolContext t
project = BuildProject.load(path);

Map<String, PackageManifest.Platform> platforms = project.currentPackage().manifest().platforms();
if (Objects.nonNull(platforms) && platforms.containsKey("java17")) {
Optional<Map<String, Object>> nativeDependency = platforms.get("java17").dependencies().stream().filter(
if (Objects.nonNull(platforms) && platforms.containsKey("java21")) {
Optional<Map<String, Object>> nativeDependency = platforms.get("java21").dependencies().stream().filter(
dependency -> dependency.containsKey("groupId") &&
dependency.get("groupId").equals("io.ballerina.openapi")
&& dependency.containsKey("artifactId") &&
Expand All @@ -439,7 +439,7 @@ private boolean clientNativeDependencyAlreadyExist(String version, ToolContext t
private NodeList<DocumentMemberDeclarationNode> populateClientNativeDependency(
NodeList<DocumentMemberDeclarationNode> tomlMembers, String version) {
String desc = "This dependency is added automatically by the OpenAPI tool. DO NOT REMOVE UNLESS REQUIRED";
tomlMembers = tomlMembers.add(SampleNodeGenerator.createTableArray("platform.java17.dependency", desc));
tomlMembers = tomlMembers.add(SampleNodeGenerator.createTableArray("platform.java21.dependency", desc));
tomlMembers = tomlMembers.add(SampleNodeGenerator.createStringKV("groupId", "io.ballerina.openapi", null));
tomlMembers = tomlMembers.add(SampleNodeGenerator.createStringKV("artifactId", "client-native", null));
tomlMembers = tomlMembers.add(SampleNodeGenerator.createStringKV("version", version, null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,8 @@ private void updateBallerinaTomlWithClientNativeDependency() {
private boolean clientNativeDependencyAlreadyExist(String version) {
Project project = ProjectLoader.loadProject(executionPath);
Map<String, Platform> platforms = project.currentPackage().manifest().platforms();
if (Objects.nonNull(platforms) && platforms.containsKey("java17")) {
Optional<Map<String, Object>> nativeDependency = platforms.get("java17").dependencies().stream().filter(
if (Objects.nonNull(platforms) && platforms.containsKey("java21")) {
Optional<Map<String, Object>> nativeDependency = platforms.get("java21").dependencies().stream().filter(
dependency -> dependency.containsKey("groupId") &&
dependency.get("groupId").equals("io.ballerina.openapi")
&& dependency.containsKey("artifactId") &&
Expand Down Expand Up @@ -565,7 +565,7 @@ private boolean clientNativeDependencyAlreadyExist(String version) {
private NodeList<DocumentMemberDeclarationNode> populateClientNativeDependency(
NodeList<DocumentMemberDeclarationNode> tomlMembers, String version) {
String desc = "This dependency is added automatically by the OpenAPI tool. DO NOT REMOVE UNLESS REQUIRED";
tomlMembers = tomlMembers.add(SampleNodeGenerator.createTableArray("platform.java17.dependency", desc));
tomlMembers = tomlMembers.add(SampleNodeGenerator.createTableArray("platform.java21.dependency", desc));
tomlMembers = tomlMembers.add(SampleNodeGenerator.createStringKV("groupId", "io.ballerina.openapi", null));
tomlMembers = tomlMembers.add(SampleNodeGenerator.createStringKV("artifactId", "client-native", null));
tomlMembers = tomlMembers.add(SampleNodeGenerator.createStringKV("version", version, null));
Expand Down
4 changes: 2 additions & 2 deletions openapi-client-native/ballerina-tests/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
org = "ballerina"
name = "client_native_test"
version = "0.1.0"
distribution = "2201.8.6"
distribution = "2201.10.0-20241025-103700-5c9e6a27"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "io.ballerina.openapi"
artifactId = "client-native"
version = "1.0.1-SNAPSHOT"
Expand Down
4 changes: 2 additions & 2 deletions openapi-client-native/build-configs/resources/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
org = "ballerina"
name = "client_native_test"
version = "0.1.0"
distribution = "2201.8.6"
distribution = "2201.10.0-20241025-103700-5c9e6a27"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "io.ballerina.openapi"
artifactId = "client-native"
version = "@client.native.version@"
Expand Down
7 changes: 5 additions & 2 deletions openapi-client-native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ checkstyleMain.dependsOn(":checkstyle:downloadCheckstyleRuleFiles")
checkstyleTest.dependsOn(":checkstyle:downloadCheckstyleRuleFiles")

spotbugsMain {
def classLoader = plugins["com.github.spotbugs"].class.classLoader
def SpotBugsConfidence = classLoader.findLoadedClass("com.github.spotbugs.snom.Confidence")
def SpotBugsEffort = classLoader.findLoadedClass("com.github.spotbugs.snom.Effort")
effort = SpotBugsEffort.MAX
reportLevel = SpotBugsConfidence.LOW
ignoreFailures = true
effort = "max"
reportLevel = "low"
reportsDir = file("$project.buildDir/reports/spotbugs")
def excludeFile = file("${rootDir}/spotbugs-exclude.xml")
if (excludeFile.exists()) {
Expand Down
8 changes: 8 additions & 0 deletions spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,12 @@
<Method name="getResourceFunction"/>
<Bug pattern="BC_UNCONFIRMED_CAST" />
</Match>
<Match>
<Class name="io.ballerina.openapi.service.mapper.interceptor.types.Interceptor" />
<Bug pattern="CT_CONSTRUCTOR_THROW" />
</Match>
<Match>
<Class name="io.ballerina.openapi.cmd.ErrorMessages" />
<Bug pattern="CT_CONSTRUCTOR_THROW" />
</Match>
</FindBugsFilter>

0 comments on commit a5656ea

Please sign in to comment.