From 7deb8bfed9d5a383eff3b78535372180865bb2b2 Mon Sep 17 00:00:00 2001 From: Norbel AMBANUMBEN Date: Fri, 3 Nov 2023 08:33:11 +0100 Subject: [PATCH] Upgrade gradle to `8.1.2` and add support for kotlin and `kapt` (#627) ## Proposed Changes - Upgrade `gradle` to `8.1.2` - Add support for `kotlin` and `kapt` to serve as base for writing kotlin code moving forward --- .github/workflows/archive.yml | 2 +- .github/workflows/build.yml | 2 +- .github/workflows/emulator.yml | 2 +- .github/workflows/test.yml | 2 +- app/build.gradle | 18 +++++++++++------- app/jacoco.gradle | 20 +++++++++++++------- gradle.properties | 3 +++ gradle/libs.versions.toml | 8 ++++---- gradle/wrapper/gradle-wrapper.properties | 2 +- shared-test/build.gradle | 21 +++++++++++++-------- 10 files changed, 49 insertions(+), 31 deletions(-) diff --git a/.github/workflows/archive.yml b/.github/workflows/archive.yml index d41537923..40344f610 100644 --- a/.github/workflows/archive.yml +++ b/.github/workflows/archive.yml @@ -7,7 +7,7 @@ jobs: steps: - uses: actions/setup-java@v2 with: - java-version: '11' + java-version: '17' distribution: 'temurin' - name: checkout uses: actions/checkout@v2 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6ed6c7a7e..46f49645d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/setup-java@v2 with: - java-version: '11' + java-version: '17' distribution: 'temurin' - name: checkout uses: actions/checkout@v2 diff --git a/.github/workflows/emulator.yml b/.github/workflows/emulator.yml index 0a599c15a..de92c9393 100644 --- a/.github/workflows/emulator.yml +++ b/.github/workflows/emulator.yml @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/setup-java@v2 with: - java-version: '11' + java-version: '17' distribution: 'temurin' - name: checkout uses: actions/checkout@v2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e678fedd6..f743fca58 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,7 @@ jobs: steps: - uses: actions/setup-java@v2 with: - java-version: '11' + java-version: '17' distribution: 'temurin' - name: checkout uses: actions/checkout@v2 diff --git a/app/build.gradle b/app/build.gradle index 60987f4f8..e61731ad2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,7 @@ plugins { id 'com.android.application' - id 'org.jetbrains.kotlin.android' + id 'kotlin-android' + id 'kotlin-kapt' } apply from: 'jacoco.gradle' @@ -85,8 +86,11 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = JavaVersion.VERSION_17 } buildFeatures { viewBinding = true @@ -111,7 +115,7 @@ dependencies { implementation libs.google.gson // Third-party - annotationProcessor libs.dbflow.processor + kapt libs.dbflow.processor implementation libs.dbflow.core implementation libs.dbflow.lib @@ -136,7 +140,7 @@ dependencies { // Dependency Injection implementation libs.google.dagger - annotationProcessor libs.google.dagger.compiler + kapt libs.google.dagger.compiler // Logger implementation project(':applogger') @@ -153,7 +157,7 @@ dependencies { testImplementation libs.robolectric testImplementation libs.faker testImplementation libs.ooni.oonimkall - testAnnotationProcessor libs.google.dagger.compiler + kaptTest libs.google.dagger.compiler // Instrumentation Testing androidTestImplementation project(':shared-test') @@ -166,7 +170,7 @@ dependencies { androidTestImplementation libs.androidx.espresso.contrib androidTestImplementation libs.androidx.espresso.core androidTestImplementation libs.barista - androidTestAnnotationProcessor libs.google.dagger.compiler + kaptAndroidTest libs.google.dagger.compiler } static def versionCodeDate() { diff --git a/app/jacoco.gradle b/app/jacoco.gradle index f75812752..15b2b36c1 100644 --- a/app/jacoco.gradle +++ b/app/jacoco.gradle @@ -48,13 +48,19 @@ task jacocoAndroidTestReport(type: JacocoReport) { executionData.from += fileTree(dir: codeCoverageDataLocation, includes: ['**/*.ec']) } - reports { - html.enabled true - html.destination file("${buildDir}/reports/coverage") - xml.enabled true - xml.destination file("${buildDir}/reports/coverage.xml") - csv.enabled false - } + reports { + html { + enabled true + destination file("${buildDir}/reports/coverage") + } + xml { + enabled true + destination file("${buildDir}/reports/coverage.xml") + } + csv { + enabled false + } + } doLast { println "Wrote HTML coverage report to ${reports.html.destination}/index.html" diff --git a/gradle.properties b/gradle.properties index 8de505811..a8c570082 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,10 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. +android.defaults.buildfeatures.buildconfig=true android.enableJetifier=true +android.nonFinalResIds=false +android.nonTransitiveRClass=false android.useAndroidX=true org.gradle.jvmargs=-Xmx1536m # When configured, Gradle will run in incubating parallel mode. diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a58947f9d..2421c03c3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,16 +1,16 @@ [versions] -androidGradlePlugin = "7.4.1" +androidGradlePlugin = "8.1.2" barista = "3.9.0" countlySdk = "23.6.0" faker = "1.2.8" mockitoCore = "5.3.1" mockitoInline = "4.6.1" -robolectric = "4.6.1" +robolectric = "4.10.3" fastlaneScreengrab = "2.0.0" sentryAndroid = "6.3.0" xanscaleLocalhostToolkit = "19.05.01" commonsIo = "2.6" -jacoco = "0.8.5" +jacoco = "0.8.7" kotlin = "1.8.0" # Android X @@ -29,7 +29,7 @@ androidxEspressoCore = "3.5.1" googleGson = "2.8.9" googleGuava = "30.1.1-android" googleMaterial = "1.6.1" -googleDagger = "2.36" +googleDagger = "2.45" googleFirebaseBon = "26.3.0" googlePlaycore = "1.10.3" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2ec77e51a..3a0290794 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/shared-test/build.gradle b/shared-test/build.gradle index 607a28dff..34d70a978 100644 --- a/shared-test/build.gradle +++ b/shared-test/build.gradle @@ -1,18 +1,22 @@ plugins { id 'com.android.library' + id 'kotlin-android' + id 'kotlin-kapt' } android { namespace 'org.openobservatory.ooniprobe.shared.test' - compileSdk 33 + compileSdk libs.versions.compileSdk.get().toInteger() defaultConfig { - minSdk 21 + minSdk libs.versions.minSdk.get().toInteger() } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + compileOptions { + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = JavaVersion.VERSION_17 } flavorDimensions = ['testing', 'license'] productFlavors { @@ -41,12 +45,12 @@ dependencies { // Dependency Injection (https://dagger.dev/) implementation libs.google.dagger - annotationProcessor libs.google.dagger.compiler + kapt libs.google.dagger.compiler // Database Library (https://github.com/agrosner/DBFlow) implementation libs.dbflow.core implementation libs.dbflow.lib - annotationProcessor libs.dbflow.processor + kapt libs.dbflow.processor // Gson Serialization Library (https://github.com/google/gson) implementation libs.google.gson @@ -60,6 +64,7 @@ dependencies { implementation libs.retrofit.logging.interceptor implementation libs.androidx.appcompat + implementation libs.xanscale.localhost.toolkit testImplementation libs.junit4 androidTestImplementation libs.androidx.junit