diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a9f751b556..98660acf30 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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: diff --git a/.github/workflows/build_enterprise.yml b/.github/workflows/build_enterprise.yml index 601db71ac7..c20d87c809 100644 --- a/.github/workflows/build_enterprise.yml +++ b/.github/workflows/build_enterprise.yml @@ -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: diff --git a/.github/workflows/generate_github_pages.yml b/.github/workflows/generate_github_pages.yml index c86c5799e3..e39175c755 100644 --- a/.github/workflows/generate_github_pages.yml +++ b/.github/workflows/generate_github_pages.yml @@ -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: diff --git a/.github/workflows/gradle-wrapper-update.yml b/.github/workflows/gradle-wrapper-update.yml index fe2a8a7cf1..f5a5b3c94c 100644 --- a/.github/workflows/gradle-wrapper-update.yml +++ b/.github/workflows/gradle-wrapper-update.yml @@ -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: diff --git a/.github/workflows/maestro.yml b/.github/workflows/maestro.yml index bbf1129eff..6ba8279e60 100644 --- a/.github/workflows/maestro.yml +++ b/.github/workflows/maestro.yml @@ -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: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 67c53ccbae..e661dc02ff 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -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 diff --git a/.github/workflows/nightlyReports.yml b/.github/workflows/nightlyReports.yml index bb1af3abc4..3b8184f6af 100644 --- a/.github/workflows/nightlyReports.yml +++ b/.github/workflows/nightlyReports.yml @@ -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: 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: diff --git a/.github/workflows/nightly_enterprise.yml b/.github/workflows/nightly_enterprise.yml index 611986010e..677977e5c4 100644 --- a/.github/workflows/nightly_enterprise.yml +++ b/.github/workflows/nightly_enterprise.yml @@ -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 diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index 37d86a51de..5d69ac3c64 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -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: - 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: - 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: - 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: - 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: - 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: diff --git a/.github/workflows/recordScreenshots.yml b/.github/workflows/recordScreenshots.yml index 1391aca49c..e7a30ec9fb 100644 --- a/.github/workflows/recordScreenshots.yml +++ b/.github/workflows/recordScreenshots.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 17ab2efd18..87ffcb76fe 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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: 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: 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 diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml index 1a9f2cf598..cda6219c26 100644 --- a/.github/workflows/sonar.yml +++ b/.github/workflows/sonar.yml @@ -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: diff --git a/.github/workflows/sync-localazy.yml b/.github/workflows/sync-localazy.yml index f559386ffe..dc688cb5a4 100644 --- a/.github/workflows/sync-localazy.yml +++ b/.github/workflows/sync-localazy.yml @@ -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: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 45630e6140..897abf8d55 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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: diff --git a/app/build.gradle.kts b/app/build.gradle.kts index b760bd63e1..a63de43391 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -161,9 +161,6 @@ android { } } } - kotlinOptions { - jvmTarget = "17" - } buildFeatures { buildConfig = true diff --git a/libraries/core/build.gradle.kts b/libraries/core/build.gradle.kts index ca011fcf14..841fe8401a 100644 --- a/libraries/core/build.gradle.kts +++ b/libraries/core/build.gradle.kts @@ -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 { diff --git a/libraries/core/src/main/kotlin/io/element/android/libraries/core/uri/UrlUtils.kt b/libraries/core/src/main/kotlin/io/element/android/libraries/core/uri/UrlUtils.kt index 30ac225a96..a746586f45 100644 --- a/libraries/core/src/main/kotlin/io/element/android/libraries/core/uri/UrlUtils.kt +++ b/libraries/core/src/main/kotlin/io/element/android/libraries/core/uri/UrlUtils.kt @@ -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 diff --git a/libraries/dateformatter/impl/src/test/kotlin/io/element/android/libraries/dateformatter/impl/DefaultLastMessageTimestampFormatterTest.kt b/libraries/dateformatter/impl/src/test/kotlin/io/element/android/libraries/dateformatter/impl/DefaultLastMessageTimestampFormatterTest.kt index 4d1a581371..c1a684cdf5 100644 --- a/libraries/dateformatter/impl/src/test/kotlin/io/element/android/libraries/dateformatter/impl/DefaultLastMessageTimestampFormatterTest.kt +++ b/libraries/dateformatter/impl/src/test/kotlin/io/element/android/libraries/dateformatter/impl/DefaultLastMessageTimestampFormatterTest.kt @@ -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:35 PM") } @Test @@ -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:35 PM") } @Test @@ -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:34 PM") } @Test @@ -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:35 PM") } @Test diff --git a/plugins/src/main/kotlin/Versions.kt b/plugins/src/main/kotlin/Versions.kt index 4f1d15ee71..71a5c65c8b 100644 --- a/plugins/src/main/kotlin/Versions.kt +++ b/plugins/src/main/kotlin/Versions.kt @@ -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) } diff --git a/plugins/src/main/kotlin/extension/CommonExtension.kt b/plugins/src/main/kotlin/extension/CommonExtension.kt index a18ed6c32c..32e27b516e 100644 --- a/plugins/src/main/kotlin/extension/CommonExtension.kt +++ b/plugins/src/main/kotlin/extension/CommonExtension.kt @@ -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) { } compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = Versions.javaVersion + targetCompatibility = Versions.javaVersion } testOptions { diff --git a/plugins/src/main/kotlin/extension/KoverExtension.kt b/plugins/src/main/kotlin/extension/KoverExtension.kt index 38a43c33dd..6182fde1f5 100644 --- a/plugins/src/main/kotlin/extension/KoverExtension.kt +++ b/plugins/src/main/kotlin/extension/KoverExtension.kt @@ -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.*", ) } } diff --git a/plugins/src/main/kotlin/io.element.android-compose-application.gradle.kts b/plugins/src/main/kotlin/io.element.android-compose-application.gradle.kts index e537aaa851..6773164f46 100644 --- a/plugins/src/main/kotlin/io.element.android-compose-application.gradle.kts +++ b/plugins/src/main/kotlin/io.element.android-compose-application.gradle.kts @@ -29,6 +29,12 @@ android { } } +kotlin { + jvmToolchain { + languageVersion = Versions.javaLanguageVersion + } +} + dependencies { commonDependencies(libs) composeDependencies(libs) diff --git a/plugins/src/main/kotlin/io.element.android-compose-library.gradle.kts b/plugins/src/main/kotlin/io.element.android-compose-library.gradle.kts index 47dac35882..5c6c6a3589 100644 --- a/plugins/src/main/kotlin/io.element.android-compose-library.gradle.kts +++ b/plugins/src/main/kotlin/io.element.android-compose-library.gradle.kts @@ -29,6 +29,12 @@ android { } } +kotlin { + jvmToolchain { + languageVersion = Versions.javaLanguageVersion + } +} + dependencies { commonDependencies(libs) composeDependencies(libs) diff --git a/plugins/src/main/kotlin/io.element.android-library.gradle.kts b/plugins/src/main/kotlin/io.element.android-library.gradle.kts index 472ab90fbc..f34c884091 100644 --- a/plugins/src/main/kotlin/io.element.android-library.gradle.kts +++ b/plugins/src/main/kotlin/io.element.android-library.gradle.kts @@ -26,6 +26,12 @@ android { } } +kotlin { + jvmToolchain { + languageVersion = Versions.javaLanguageVersion + } +} + dependencies { commonDependencies(libs) coreLibraryDesugaring(libs.android.desugar)