From 43ff9681b8468e3bcc4ed39065bc2b3650e61157 Mon Sep 17 00:00:00 2001 From: Javier Delgado Aylagas Date: Mon, 2 Dec 2024 17:13:18 +0100 Subject: [PATCH 01/11] Use TOML file --- app/build.gradle | 2 +- gradle/libs.versions.toml | 19 +++++++++++++++++++ gradle/wrapper/gradle-wrapper.properties | 4 +++- library/build.gradle | 21 ++++++++------------- 4 files changed, 31 insertions(+), 15 deletions(-) create mode 100644 gradle/libs.versions.toml diff --git a/app/build.gradle b/app/build.gradle index 5de4eac..34f94c6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -33,6 +33,6 @@ android { } dependencies { - implementation 'androidx.appcompat:appcompat:1.2.0' + implementation libs.androidx.appcompat implementation project(':library') } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..cc2679b --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,19 @@ +[versions] +junit = "4.13" +kotlin = "1.6.21" +androidx-lifecycle = "2.2.0" +material = "1.2.1" +elviswhew-xlog = "1.3.0" +okio = "2.7.0" + +[libraries] +androidx-annotation = { module = "androidx.annotation:annotation", version = "1.1.0" } +androidx-appcompat = { module = "androidx.appcompat:appcompat", version = "1.2.0" } +androidx-lifecycle-extensions = { module = "androidx.lifecycle:lifecycle-extensions", version.ref = "androidx-lifecycle" } +com-google-android-material = { module = "com.google.android.material:material", version.ref = "material" } +com-squareup-okio = { module = "com.squareup.okio:okio", version.ref = "okio" } +junit = { module = "junit:junit", version.ref = "junit" } +org-jetbrains-kotlin = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" } +elvishew-xlog = { module = "com.elvishew:xlog", version.ref = "elviswhew-xlog" } + +[plugins] diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8049c68..09523c0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/library/build.gradle b/library/build.gradle index 0edd4ac..ccf2da9 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -3,12 +3,7 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { - compileSdkVersion 33 - - defaultConfig { - minSdkVersion 21 - targetSdkVersion 33 - } + compileSdk 33 flavorDimensions "loggerMode" productFlavors { @@ -35,14 +30,14 @@ android { dependencies { //noinspection GradleDependency - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation "androidx.annotation:annotation:1.1.0" - enabledImplementation "com.google.android.material:material:$support_version" - enabledImplementation "androidx.lifecycle:lifecycle-extensions:2.2.0" - enabledImplementation "com.elvishew:xlog:1.11.0" - enabledImplementation "com.squareup.okio:okio:2.7.0" + implementation libs.org.jetbrains.kotlin + implementation libs.androidx.annotation + enabledImplementation libs.com.google.android.material + enabledImplementation libs.androidx.lifecycle.extensions + enabledImplementation libs.elvishew.xlog + enabledImplementation libs.com.squareup.okio - testImplementation 'junit:junit:4.13' + testImplementation libs.junit } apply from: "${rootProject.projectDir}/mavencentral.gradle" From d532a51c3c89d18b463eafbefad5b4db9178da26 Mon Sep 17 00:00:00 2001 From: Javier Delgado Aylagas Date: Mon, 2 Dec 2024 17:13:31 +0100 Subject: [PATCH 02/11] Update AGP --- build.gradle | 2 +- gradle.properties | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index b635584..3380272 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { } } dependencies { - classpath 'com.android.tools.build:gradle:7.4.2' + classpath 'com.android.tools.build:gradle:8.7.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong diff --git a/gradle.properties b/gradle.properties index 3aec1b6..35b4419 100644 --- a/gradle.properties +++ b/gradle.properties @@ -23,3 +23,6 @@ android.r8.failOnMissingClasses=true ###### Project settings ###### kotlin.code.style=official +android.defaults.buildfeatures.buildconfig=true +android.nonTransitiveRClass=false +android.nonFinalResIds=false From 22cc106a83f6f2484f6ec9d7684e1aad0fc45b48 Mon Sep 17 00:00:00 2001 From: Javier Delgado Aylagas Date: Mon, 2 Dec 2024 18:06:46 +0100 Subject: [PATCH 03/11] Update libraries --- app/build.gradle | 9 ++++----- build.gradle | 17 ++++++----------- gradle.properties | 6 ------ gradle/libs.versions.toml | 20 +++++++++++++------- library/build.gradle | 14 ++++++++++---- settings.gradle | 8 ++++++++ 6 files changed, 41 insertions(+), 33 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 34f94c6..8adbff9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,16 +1,15 @@ plugins { - id 'com.android.application' - id 'kotlin-android' + alias libs.plugins.com.android.application + alias libs.plugins.kotlin.android } android { - compileSdkVersion 33 - //noinspection GradleDependency + compileSdk 34 defaultConfig { applicationId "com.telefonica.androidlogger.app" minSdkVersion 21 - targetSdkVersion 33 + targetSdkVersion 34 versionCode 1 versionName "1.0.0" diff --git a/build.gradle b/build.gradle index 3380272..53b2073 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,5 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.6.21' - ext.support_version = "1.2.1" repositories { google() jcenter() @@ -9,18 +7,15 @@ buildscript { url "https://plugins.gradle.org/m2/" } } - dependencies { - classpath 'com.android.tools.build:gradle:8.7.2' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } } plugins { - id("io.gitlab.arturbosch.detekt").version("1.22.0") - id 'io.github.gradle-nexus.publish-plugin' version '1.3.0' apply false + alias libs.plugins.kotlin.android apply false + alias libs.plugins.com.android.application apply false + alias libs.plugins.com.android.library apply false + alias libs.plugins.github.gradle.publish.plugin apply false + + alias libs.plugins.gitlab.arturbosch.detekt } detekt { diff --git a/gradle.properties b/gradle.properties index 35b4419..4f5c370 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,12 +14,6 @@ org.gradle.jvmargs=-Xmx6656m -Dfile.encoding=UTF-8 org.gradle.parallel=true android.useAndroidX=true -kapt.incremental.apt=true -# It's going to be deleted in Kotlin 1.8 -kapt.use.worker.api=true - -# This will be default on AGP 8.0 -android.r8.failOnMissingClasses=true ###### Project settings ###### kotlin.code.style=official diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cc2679b..a874e33 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,14 +1,15 @@ [versions] -junit = "4.13" -kotlin = "1.6.21" +android-gradle-plugin = "8.7.2" +junit = "4.13.2" +kotlin = "1.9.0" androidx-lifecycle = "2.2.0" -material = "1.2.1" -elviswhew-xlog = "1.3.0" -okio = "2.7.0" +material = "1.9.0" +elviswhew-xlog = "1.11.0" +okio = "2.10.0" [libraries] -androidx-annotation = { module = "androidx.annotation:annotation", version = "1.1.0" } -androidx-appcompat = { module = "androidx.appcompat:appcompat", version = "1.2.0" } +androidx-annotation = { module = "androidx.annotation:annotation", version = "1.9.1" } +androidx-appcompat = { module = "androidx.appcompat:appcompat", version = "1.7.0" } androidx-lifecycle-extensions = { module = "androidx.lifecycle:lifecycle-extensions", version.ref = "androidx-lifecycle" } com-google-android-material = { module = "com.google.android.material:material", version.ref = "material" } com-squareup-okio = { module = "com.squareup.okio:okio", version.ref = "okio" } @@ -17,3 +18,8 @@ org-jetbrains-kotlin = { module = "org.jetbrains.kotlin:kotlin-stdlib", version. elvishew-xlog = { module = "com.elvishew:xlog", version.ref = "elviswhew-xlog" } [plugins] +com-android-application = { id = "com.android.application", version.ref = "android-gradle-plugin" } +com-android-library = { id = "com.android.library", version.ref = "android-gradle-plugin" } +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +gitlab-arturbosch-detekt = "io.gitlab.arturbosch.detekt:1.23.7" +github-gradle-publish-plugin = { id = "io.github.gradle-nexus.publish-plugin", version = "1.2.0" } diff --git a/library/build.gradle b/library/build.gradle index ccf2da9..4a0515c 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,9 +1,15 @@ -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' +plugins{ + alias libs.plugins.kotlin.android + alias libs.plugins.com.android.library +} android { - compileSdk 33 + compileSdk 34 + + defaultConfig { + minSdkVersion 21 + targetSdkVersion 34 + } flavorDimensions "loggerMode" productFlavors { diff --git a/settings.gradle b/settings.gradle index d8ffba1..17c5927 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,10 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + include ':app' include ':library' From 7148c05f63995097d2220352e1817e664c54c8af Mon Sep 17 00:00:00 2001 From: Javier Delgado Aylagas Date: Mon, 2 Dec 2024 18:11:56 +0100 Subject: [PATCH 04/11] Update Java --- app/build.gradle | 6 +++--- build.gradle | 2 +- library/build.gradle | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 8adbff9..e7f2ce4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -22,11 +22,11 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = '11' + jvmTarget = '17' } namespace 'com.telefonica.androidlogger.app' } diff --git a/build.gradle b/build.gradle index 53b2073..94ec688 100644 --- a/build.gradle +++ b/build.gradle @@ -32,7 +32,7 @@ detekt { } } -tasks.detekt.jvmTarget = "11" +tasks.detekt.jvmTarget = "17" allprojects { diff --git a/library/build.gradle b/library/build.gradle index 4a0515c..495b93c 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -25,11 +25,11 @@ android { lintConfig file('lint-custom.xml') } compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = '11' + jvmTarget = '17' } namespace 'com.telefonica.androidlogger' } From 38fb724344dca99bda6fd9b183e8cd86d7f752f8 Mon Sep 17 00:00:00 2001 From: Javier Delgado Aylagas Date: Mon, 2 Dec 2024 18:17:07 +0100 Subject: [PATCH 05/11] Fix detekt --- .../main/java/com/telefonica/androidlogger/app/MainActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/telefonica/androidlogger/app/MainActivity.kt b/app/src/main/java/com/telefonica/androidlogger/app/MainActivity.kt index 63aaa4f..5b91732 100644 --- a/app/src/main/java/com/telefonica/androidlogger/app/MainActivity.kt +++ b/app/src/main/java/com/telefonica/androidlogger/app/MainActivity.kt @@ -20,7 +20,7 @@ class MainActivity : AppCompatActivity() { private fun setupViews() { findViewById