Browse Source

Upgrade the used JDK in the project to v21 (#3582)

* Upgrade the used JDK in the project to v21

* Use it for CI too

* Centralise java language version

* Fix deprecations, tests and lint issues

* Fix coverage taking into account `@Preview` annotated code.

---------

Co-authored-by: Benoit Marty <benoit@matrix.org>
pull/3591/head
Jorge Martin Espinosa 2 weeks ago committed by GitHub
parent
commit
f8fa218146
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      .github/workflows/build.yml
  2. 4
      .github/workflows/build_enterprise.yml
  3. 4
      .github/workflows/generate_github_pages.yml
  4. 4
      .github/workflows/gradle-wrapper-update.yml
  5. 4
      .github/workflows/maestro.yml
  6. 4
      .github/workflows/nightly.yml
  7. 8
      .github/workflows/nightlyReports.yml
  8. 4
      .github/workflows/nightly_enterprise.yml
  9. 24
      .github/workflows/quality.yml
  10. 4
      .github/workflows/recordScreenshots.yml
  11. 12
      .github/workflows/release.yml
  12. 4
      .github/workflows/sonar.yml
  13. 4
      .github/workflows/sync-localazy.yml
  14. 4
      .github/workflows/tests.yml
  15. 3
      app/build.gradle.kts
  16. 10
      libraries/core/build.gradle.kts
  17. 4
      libraries/core/src/main/kotlin/io/element/android/libraries/core/uri/UrlUtils.kt
  18. 8
      libraries/dateformatter/impl/src/test/kotlin/io/element/android/libraries/dateformatter/impl/DefaultLastMessageTimestampFormatterTest.kt
  19. 7
      plugins/src/main/kotlin/Versions.kt
  20. 5
      plugins/src/main/kotlin/extension/CommonExtension.kt
  21. 3
      plugins/src/main/kotlin/extension/KoverExtension.kt
  22. 6
      plugins/src/main/kotlin/io.element.android-compose-application.gradle.kts
  23. 6
      plugins/src/main/kotlin/io.element.android-compose-library.gradle.kts
  24. 6
      plugins/src/main/kotlin/io.element.android-library.gradle.kts

4
.github/workflows/build.yml

@ -30,11 +30,11 @@ jobs: @@ -30,11 +30,11 @@ jobs:
# Ensure we are building the branch and not the branch after being merged on develop
# https://github.com/actions/checkout/issues/881
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }}
- name: Use JDK 17
- name: Use JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '21'
- name: Configure gradle
uses: gradle/actions/setup-gradle@v4
with:

4
.github/workflows/build_enterprise.yml

@ -38,11 +38,11 @@ jobs: @@ -38,11 +38,11 @@ jobs:
ssh-private-key: ${{ secrets.ELEMENT_ENTERPRISE_DEPLOY_KEY }}
- name: Clone submodules
run: git submodule update --init --recursive
- name: Use JDK 17
- name: Use JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '21'
- name: Configure gradle
uses: gradle/actions/setup-gradle@v4
with:

4
.github/workflows/generate_github_pages.yml

@ -13,11 +13,11 @@ jobs: @@ -13,11 +13,11 @@ jobs:
steps:
- name: ⏬ Checkout with LFS
uses: nschloe/action-cached-lfs-checkout@v1.2.2
- name: Use JDK 17
- name: Use JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '21'
- name: Configure gradle
uses: gradle/actions/setup-gradle@v4
with:

4
.github/workflows/gradle-wrapper-update.yml

@ -13,11 +13,11 @@ jobs: @@ -13,11 +13,11 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
name: Use JDK 17
name: Use JDK 21
if: (github.event_name == 'pull_request' && github.event.pull_request.fork == null) || github.event_name == 'workflow_dispatch'
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '21'
- name: Update Gradle Wrapper
uses: gradle-update/update-gradle-wrapper-action@v2
with:

4
.github/workflows/maestro.yml

@ -33,11 +33,11 @@ jobs: @@ -33,11 +33,11 @@ jobs:
# https://github.com/actions/checkout/issues/881
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }}
- uses: actions/setup-java@v4
name: Use JDK 17
name: Use JDK 21
if: (github.event_name == 'pull_request' && github.event.pull_request.fork == null) || github.event_name == 'workflow_dispatch'
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '21'
- name: Configure gradle
uses: gradle/actions/setup-gradle@v4
with:

4
.github/workflows/nightly.yml

@ -17,11 +17,11 @@ jobs: @@ -17,11 +17,11 @@ jobs:
if: ${{ github.repository == 'element-hq/element-x-android' }}
steps:
- uses: actions/checkout@v4
- name: Use JDK 17
- name: Use JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '21'
- name: Build and upload Nightly application
run: |
./gradlew assembleGplayNightly appDistributionUploadGplayNightly $CI_GRADLE_ARG_PROPERTIES

8
.github/workflows/nightlyReports.yml

@ -20,11 +20,11 @@ jobs: @@ -20,11 +20,11 @@ jobs:
- name: ⏬ Checkout with LFS
uses: nschloe/action-cached-lfs-checkout@v1.2.2
- name: Use JDK 17
- name: Use JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '21'
- name: Configure gradle
uses: gradle/actions/setup-gradle@v4
@ -61,11 +61,11 @@ jobs: @@ -61,11 +61,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use JDK 17
- name: Use JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '21'
- name: Configure gradle
uses: gradle/actions/setup-gradle@v4
with:

4
.github/workflows/nightly_enterprise.yml

@ -23,11 +23,11 @@ jobs: @@ -23,11 +23,11 @@ jobs:
ssh-private-key: ${{ secrets.ELEMENT_ENTERPRISE_DEPLOY_KEY }}
- name: Clone submodules
run: git submodule update --init --recursive
- name: Use JDK 17
- name: Use JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '21'
- name: Build and upload Nightly application
run: |
./gradlew assembleGplayNightly appDistributionUploadGplayNightly $CI_GRADLE_ARG_PROPERTIES

24
.github/workflows/quality.yml

@ -46,11 +46,11 @@ jobs: @@ -46,11 +46,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use JDK 17
- name: Use JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '21'
- name: Configure gradle
uses: gradle/actions/setup-gradle@v4
with:
@ -84,11 +84,11 @@ jobs: @@ -84,11 +84,11 @@ jobs:
- name: Clone submodules
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'element-hq/element-x-android' }}
run: git submodule update --init --recursive
- name: Use JDK 17
- name: Use JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '21'
- name: Configure gradle
uses: gradle/actions/setup-gradle@v4
with:
@ -124,11 +124,11 @@ jobs: @@ -124,11 +124,11 @@ jobs:
- name: Clone submodules
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'element-hq/element-x-android' }}
run: git submodule update --init --recursive
- name: Use JDK 17
- name: Use JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '21'
- name: Configure gradle
uses: gradle/actions/setup-gradle@v4
with:
@ -168,11 +168,11 @@ jobs: @@ -168,11 +168,11 @@ jobs:
- name: Clone submodules
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'element-hq/element-x-android' }}
run: git submodule update --init --recursive
- name: Use JDK 17
- name: Use JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '21'
- name: Configure gradle
uses: gradle/actions/setup-gradle@v4
with:
@ -208,11 +208,11 @@ jobs: @@ -208,11 +208,11 @@ jobs:
- name: Clone submodules
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'element-hq/element-x-android' }}
run: git submodule update --init --recursive
- name: Use JDK 17
- name: Use JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '21'
- name: Configure gradle
uses: gradle/actions/setup-gradle@v4
with:
@ -248,11 +248,11 @@ jobs: @@ -248,11 +248,11 @@ jobs:
- name: Clone submodules
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'element-hq/element-x-android' }}
run: git submodule update --init --recursive
- name: Use JDK 17
- name: Use JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '21'
- name: Configure gradle
uses: gradle/actions/setup-gradle@v4
with:

4
.github/workflows/recordScreenshots.yml

@ -32,11 +32,11 @@ jobs: @@ -32,11 +32,11 @@ jobs:
uses: nschloe/action-cached-lfs-checkout@v1.2.2
with:
persist-credentials: false
- name: Use JDK 17
- name: Use JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '21'
# Add gradle cache, this should speed up the process
- name: Configure gradle
uses: gradle/actions/setup-gradle@v4

12
.github/workflows/release.yml

@ -19,11 +19,11 @@ jobs: @@ -19,11 +19,11 @@ jobs:
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
- name: Use JDK 17
- name: Use JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '21'
- name: Configure gradle
uses: gradle/actions/setup-gradle@v4
- name: Create app bundle
@ -55,11 +55,11 @@ jobs: @@ -55,11 +55,11 @@ jobs:
ssh-private-key: ${{ secrets.ELEMENT_ENTERPRISE_DEPLOY_KEY }}
- name: Clone submodules
run: git submodule update --init --recursive
- name: Use JDK 17
- name: Use JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '21'
- name: Configure gradle
uses: gradle/actions/setup-gradle@v4
- name: Create Enterprise app bundle
@ -83,11 +83,11 @@ jobs: @@ -83,11 +83,11 @@ jobs:
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
- name: Use JDK 17
- name: Use JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '21'
- name: Configure gradle
uses: gradle/actions/setup-gradle@v4
- name: Create APKs

4
.github/workflows/sonar.yml

@ -27,11 +27,11 @@ jobs: @@ -27,11 +27,11 @@ jobs:
# Ensure we are building the branch and not the branch after being merged on develop
# https://github.com/actions/checkout/issues/881
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }}
- name: Use JDK 17
- name: Use JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '21'
- name: Configure gradle
uses: gradle/actions/setup-gradle@v4
with:

4
.github/workflows/sync-localazy.yml

@ -12,11 +12,11 @@ jobs: @@ -12,11 +12,11 @@ jobs:
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'element-hq/element-x-android' }}
steps:
- uses: actions/checkout@v4
- name: Use JDK 17
- name: Use JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '21'
- name: Configure gradle
uses: gradle/actions/setup-gradle@v4
with:

4
.github/workflows/tests.yml

@ -46,11 +46,11 @@ jobs: @@ -46,11 +46,11 @@ jobs:
- name: Clone submodules
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'element-hq/element-x-android' }}
run: git submodule update --init --recursive
- name: Use JDK 17
- name: Use JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '21'
- name: Configure gradle
uses: gradle/actions/setup-gradle@v4
with:

3
app/build.gradle.kts

@ -161,9 +161,6 @@ android { @@ -161,9 +161,6 @@ android {
}
}
}
kotlinOptions {
jvmTarget = "17"
}
buildFeatures {
buildConfig = true

10
libraries/core/build.gradle.kts

@ -11,8 +11,14 @@ plugins { @@ -11,8 +11,14 @@ plugins {
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = Versions.javaVersion
targetCompatibility = Versions.javaVersion
}
kotlin {
jvmToolchain {
languageVersion = Versions.javaLanguageVersion
}
}
dependencies {

4
libraries/core/src/main/kotlin/io/element/android/libraries/core/uri/UrlUtils.kt

@ -7,11 +7,11 @@ @@ -7,11 +7,11 @@
package io.element.android.libraries.core.uri
import java.net.URL
import java.net.URI
fun String.isValidUrl(): Boolean {
return try {
URL(this)
URI(this).toURL()
true
} catch (t: Throwable) {
false

8
libraries/dateformatter/impl/src/test/kotlin/io/element/android/libraries/dateformatter/impl/DefaultLastMessageTimestampFormatterTest.kt

@ -36,7 +36,7 @@ class DefaultLastMessageTimestampFormatterTest { @@ -36,7 +36,7 @@ class DefaultLastMessageTimestampFormatterTest {
val now = "1980-04-06T18:35:24.00Z"
val dat = "1980-04-06T18:35:24.00Z"
val formatter = createFormatter(now)
assertThat(formatter.format(Instant.parse(dat).toEpochMilliseconds())).isEqualTo("6:35 PM")
assertThat(formatter.format(Instant.parse(dat).toEpochMilliseconds())).isEqualTo("6:35PM")
}
@Test
@ -44,7 +44,7 @@ class DefaultLastMessageTimestampFormatterTest { @@ -44,7 +44,7 @@ class DefaultLastMessageTimestampFormatterTest {
val now = "1980-04-06T18:35:24.00Z"
val dat = "1980-04-06T18:35:23.00Z"
val formatter = createFormatter(now)
assertThat(formatter.format(Instant.parse(dat).toEpochMilliseconds())).isEqualTo("6:35 PM")
assertThat(formatter.format(Instant.parse(dat).toEpochMilliseconds())).isEqualTo("6:35PM")
}
@Test
@ -52,7 +52,7 @@ class DefaultLastMessageTimestampFormatterTest { @@ -52,7 +52,7 @@ class DefaultLastMessageTimestampFormatterTest {
val now = "1980-04-06T18:35:24.00Z"
val dat = "1980-04-06T18:34:24.00Z"
val formatter = createFormatter(now)
assertThat(formatter.format(Instant.parse(dat).toEpochMilliseconds())).isEqualTo("6:34 PM")
assertThat(formatter.format(Instant.parse(dat).toEpochMilliseconds())).isEqualTo("6:34PM")
}
@Test
@ -60,7 +60,7 @@ class DefaultLastMessageTimestampFormatterTest { @@ -60,7 +60,7 @@ class DefaultLastMessageTimestampFormatterTest {
val now = "1980-04-06T18:35:24.00Z"
val dat = "1980-04-06T17:35:24.00Z"
val formatter = createFormatter(now)
assertThat(formatter.format(Instant.parse(dat).toEpochMilliseconds())).isEqualTo("5:35 PM")
assertThat(formatter.format(Instant.parse(dat).toEpochMilliseconds())).isEqualTo("5:35PM")
}
@Test

7
plugins/src/main/kotlin/Versions.kt

@ -54,8 +54,11 @@ object Versions { @@ -54,8 +54,11 @@ object Versions {
val versionName = "$versionMajor.$versionMinor.$versionPatch"
const val compileSdk = 34
const val targetSdk = 34
// When updating the `minSdk`, make sure to update the value of `minSdkVersion` in the file `tools/release/release.sh`
val minSdk = if (isEnterpriseBuild) 26 else 24
val javaCompileVersion = JavaVersion.VERSION_17
val javaLanguageVersion: JavaLanguageVersion = JavaLanguageVersion.of(11)
private const val JAVA_VERSION = 21
val javaVersion: JavaVersion = JavaVersion.toVersion(JAVA_VERSION)
val javaLanguageVersion: JavaLanguageVersion = JavaLanguageVersion.of(JAVA_VERSION)
}

5
plugins/src/main/kotlin/extension/CommonExtension.kt

@ -11,7 +11,6 @@ import Versions @@ -11,7 +11,6 @@ import Versions
import com.android.build.api.dsl.CommonExtension
import isEnterpriseBuild
import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import java.io.File
@ -28,8 +27,8 @@ fun CommonExtension<*, *, *, *, *, *>.androidConfig(project: Project) { @@ -28,8 +27,8 @@ fun CommonExtension<*, *, *, *, *, *>.androidConfig(project: Project) {
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = Versions.javaVersion
targetCompatibility = Versions.javaVersion
}
testOptions {

3
plugins/src/main/kotlin/extension/KoverExtension.kt

@ -104,8 +104,7 @@ fun Project.setupKover() { @@ -104,8 +104,7 @@ fun Project.setupKover() {
annotatedBy(
"androidx.compose.ui.tooling.preview.Preview",
"io.element.android.libraries.architecture.coverage.ExcludeFromCoverage",
"io.element.android.libraries.designsystem.preview.PreviewsDayNight",
"io.element.android.libraries.designsystem.preview.PreviewWithLargeHeight",
"io.element.android.libraries.designsystem.preview.*",
)
}
}

6
plugins/src/main/kotlin/io.element.android-compose-application.gradle.kts

@ -29,6 +29,12 @@ android { @@ -29,6 +29,12 @@ android {
}
}
kotlin {
jvmToolchain {
languageVersion = Versions.javaLanguageVersion
}
}
dependencies {
commonDependencies(libs)
composeDependencies(libs)

6
plugins/src/main/kotlin/io.element.android-compose-library.gradle.kts

@ -29,6 +29,12 @@ android { @@ -29,6 +29,12 @@ android {
}
}
kotlin {
jvmToolchain {
languageVersion = Versions.javaLanguageVersion
}
}
dependencies {
commonDependencies(libs)
composeDependencies(libs)

6
plugins/src/main/kotlin/io.element.android-library.gradle.kts

@ -26,6 +26,12 @@ android { @@ -26,6 +26,12 @@ android {
}
}
kotlin {
jvmToolchain {
languageVersion = Versions.javaLanguageVersion
}
}
dependencies {
commonDependencies(libs)
coreLibraryDesugaring(libs.android.desugar)

Loading…
Cancel
Save