From 20f23177439d4cb554eaf12eb538311d5af15dcc Mon Sep 17 00:00:00 2001 From: Martin Zeitler Date: Fri, 22 Mar 2024 20:23:45 +0100 Subject: [PATCH] migrated to version catalog. --- build.gradle | 44 +++---------------------- library/build.gradle | 38 ++++++++++----------- libs.versions.toml | 65 ++++++++++++++++++++++++++++++++++++ mobile/build.gradle | 78 +++++++++++++++++++++++--------------------- settings.gradle | 5 +++ version.properties | 2 +- 6 files changed, 134 insertions(+), 98 deletions(-) create mode 100644 libs.versions.toml diff --git a/build.gradle b/build.gradle index 1845cdac..841ce276 100644 --- a/build.gradle +++ b/build.gradle @@ -1,42 +1,8 @@ // root build.gradle -buildscript { - ext { - android_gradle_plugin_version = '8.3.1' - material_design_version = '1.11.0' - kotlin_version = '1.9.21' - retrofit_version = '2.9.0' - gson_version = '2.10.1' - junit_version = '4.13.2' - flexbox_version = '3.0.0' - - // DirCacheCheckout.java uses InputStream.transferTo() since 6.3; no such method on Android. - jgit_version = '6.2.0.202206071550-r' // instead of 6.5.0.202303070854-r - slf4j_version = '2.0.9' - - androidx_appcompat_version = '1.6.1' - androidx_annotation_version = '1.6.0' - androidx_fragment_version = '1.6.2' - androidx_navigation_version = '2.7.7' - androidx_room_version = '2.6.1' - androidx_splash_version = '1.0.1' - androidx_recyclerview_version = '1.3.2' - androidx_preference_version = '1.2.1' - androidx_cardview_version = '1.0.0' - - androidx_test_junit_version = '1.1.5' - androidx_test_core_version = '1.5.0' - androidx_test_monitor_version = '1.6.1' - androidx_test_runner_version = '1.5.2' - androidx_test_rules_version = '1.5.0' - androidx_test_uiautomator_version = '2.3.0' - androidx_test_espresso_version = '3.5.1' - } -} - plugins { - id 'com.android.application' version "$android_gradle_plugin_version" apply false - id 'com.android.library' version "$android_gradle_plugin_version" apply false - id 'androidx.navigation.safeargs' version "$androidx_navigation_version" apply false + alias(libs.plugins.android.application) apply false + alias(libs.plugins.android.library) apply false + alias(libs.plugins.androidx.navigation.safeargs) apply false } /** Version Settings, loaded from file `version.properties` */ @@ -74,9 +40,7 @@ allprojects { def requested = details.requested if (requested.group == 'org.jetbrains.kotlin') { List list = ['kotlin-stdlib', 'kotlin-stdlib-jdk7', 'kotlin-stdlib-jdk8', 'kotlin-stdlib-common'] - if (list.contains(requested.name)) { - details.useVersion "$kotlin_version" - } + if (list.contains(requested.name)) { details.useVersion libs.versions.kotlin.get() } } } } diff --git a/library/build.gradle b/library/build.gradle index 8cb130ec..6ee51419 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,5 +1,6 @@ plugins { - id 'com.android.library' + alias(libs.plugins.android.library) + alias(libs.plugins.androidx.room) id 'maven-publish' } @@ -16,20 +17,19 @@ android { targetSdk 34 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFile "${project.rootDir}/proguard/consumer.pro" - javaCompileOptions { - annotationProcessorOptions { - arguments = [ "room.schemaLocation": "$rootDir/schema".toString() ] - } - } } - sourceSets.main.java.srcDirs = [ "src/main/java" ] + room { + schemaDirectory("${rootDir}/schema") + } compileOptions { sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17 } + sourceSets.main.java.srcDirs = [ "src/main/java" ] + buildFeatures { buildConfig true dataBinding true @@ -65,31 +65,31 @@ android { dependencies { // Material Design Components - implementation "com.google.android.material:material:$material_design_version" + implementation libs.material.design // Annotations - implementation "androidx.annotation:annotation:$androidx_annotation_version" + implementation libs.androidx.annotation // App Compat - implementation "androidx.appcompat:appcompat:$androidx_appcompat_version" + implementation libs.androidx.appcompat // Data-Binding Runtime - implementation "androidx.databinding:databinding-runtime:$android_gradle_plugin_version" + implementation libs.androidx.databinding // Room Runtime - annotationProcessor "androidx.room:room-compiler:$androidx_room_version" - testImplementation "androidx.room:room-testing:$androidx_room_version" - implementation "androidx.room:room-runtime:$androidx_room_version" + annotationProcessor libs.androidx.room.compiler + testImplementation libs.androidx.room.testing + implementation libs.androidx.room.runtime // Retrofit2 - implementation "com.google.code.gson:gson:$gson_version" - implementation "com.squareup.retrofit2:retrofit:$retrofit_version" - implementation ("com.squareup.retrofit2:converter-gson:$retrofit_version") { + implementation libs.gson + implementation libs.retrofit + implementation (libs.retrofit.gson.converter) { exclude group: "com.google.code.gson", module: "gson" } - testImplementation "junit:junit:$junit_version" - androidTestImplementation "androidx.test.ext:junit:$androidx_test_junit_version" + testImplementation libs.junit + androidTestImplementation libs.androidx.test.junit } tasks.register('javadoc', Javadoc) { diff --git a/libs.versions.toml b/libs.versions.toml new file mode 100644 index 00000000..06fccd46 --- /dev/null +++ b/libs.versions.toml @@ -0,0 +1,65 @@ +[versions] +android_gradle_plugin = '8.3.1' +material_design = '1.11.0' +kotlin = '1.9.22' +retrofit = '2.9.0' +gson = '2.10.1' +junit = '4.13.2' +flexbox = '3.0.0' +jgit = '6.2.0.202206071550-r' +slf4j = '2.0.9' +androidx_appcompat = '1.6.1' +androidx_annotation = '1.7.1' +androidx_navigation = '2.7.7' +androidx_fragment = '1.6.2' +androidx_recyclerview = '1.3.2' +androidx_cardview = '1.0.0' +androidx_preference = '1.2.1' +androidx_room = '2.6.1' +androidx_splashscreen = '1.0.1' +androidx_test_junit = '1.1.5' +androidx_test_core = '1.5.0' +androidx_test_rules = '1.5.0' +androidx_test_runner = '1.5.2' +androidx_test_monitor = '1.6.1' +androidx_test_uiautomator = '2.3.0' +androidx_test_espresso = '3.5.1' + +[plugins] +android_application = { id = "com.android.application", version.ref = "android_gradle_plugin" } +android_library = { id = "com.android.library", version.ref = "android_gradle_plugin" } +androidx_navigation_safeargs = { id = "androidx.navigation.safeargs", version.ref = "androidx_navigation" } +androidx_room = { id = "androidx.room", version.ref = "androidx_room" } + +[libraries] +material_design = { module = "com.google.android.material:material", version.ref = "material_design" } +gson = { module = "com.google.code.gson:gson", version.ref = "gson" } +junit = { module = "junit:junit", version.ref = "junit" } +flexbox = { module = "com.google.android.flexbox:flexbox", version.ref = "flexbox" } +retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" } +retrofit_gson_converter = { module = "com.squareup.retrofit2:converter-gson", version.ref = "retrofit" } +# DirCacheCheckout.java uses InputStream.transferTo() since 6.3; no such method on Android. +jgit = { module = "org.eclipse.jgit:org.eclipse.jgit", version.ref = "jgit" } +slf4j = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j" } +androidx_databinding = { module = "androidx.databinding:databinding-runtime", version.ref = "android_gradle_plugin" } +androidx_appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx_appcompat" } +androidx_annotation = { module = "androidx.annotation:annotation", version.ref = "androidx_annotation" } +androidx_fragment = { module = "androidx.fragment:fragment", version.ref = "androidx_fragment" } +androidx_fragment_testing = { module = "androidx.fragment:fragment-testing", version.ref = "androidx_fragment" } +androidx_recyclerview = { module = "androidx.recyclerview:recyclerview", version.ref = "androidx_recyclerview" } +androidx_cardview = { module = "androidx.cardview:cardview", version.ref = "androidx_cardview" } +androidx_preference = { module = "androidx.preference:preference", version.ref = "androidx_preference" } +androidx_navigation_testing = { module = "androidx.navigation:navigation-testing", version.ref = "androidx_navigation" } +androidx_navigation_fragment = { module = "androidx.navigation:navigation-fragment", version.ref = "androidx_navigation" } +androidx_room_testing = { module = "androidx.room:room-testing", version.ref = "androidx_room" } +androidx_room_compiler = { module = "androidx.room:room-compiler", version.ref = "androidx_room" } +androidx_room_runtime = { module = "androidx.room:room-runtime", version.ref = "androidx_room" } +androidx_splashscreen = { module = "androidx.core:core-splashscreen", version.ref = "androidx_splashscreen" } +androidx_test_monitor = { module = "androidx.test:monitor", version.ref = "androidx_test_monitor" } +androidx_test_junit = { module = "androidx.test.ext:junit", version.ref = "androidx_test_junit" } +androidx_test_core = { module = "androidx.test:core", version.ref = "androidx_test_core" } +androidx_test_rules = { module = "androidx.test:rules", version.ref = "androidx_test_rules" } +androidx_test_runner = { module = "androidx.test:runner", version.ref = "androidx_test_runner" } +androidx_test_uiautomator = { module = "androidx.test.uiautomator:uiautomator", version.ref = "androidx_test_uiautomator" } +androidx_espresso_core = { module = "androidx.test.espresso:espresso-core", version.ref = "androidx_test_espresso" } +androidx_espresso_web = { module = "androidx.test.espresso:espresso-web", version.ref = "androidx_test_espresso" } diff --git a/mobile/build.gradle b/mobile/build.gradle index fb3fb8d6..921a94e2 100644 --- a/mobile/build.gradle +++ b/mobile/build.gradle @@ -1,7 +1,8 @@ // :mobile build.gradle plugins { - id "com.android.application" - id "androidx.navigation.safeargs" + alias(libs.plugins.android.application) + alias(libs.plugins.androidx.navigation.safeargs) + alias(libs.plugins.androidx.room) } /** Load API access-token from file `token.properties` */ @@ -27,18 +28,17 @@ android { minSdk 22 targetSdk 34 applicationId 'io.syslogic.github' + //noinspection GroovyConstructorNamedArguments manifestPlaceholders = [ accessToken: "" ] versionName rootProject.ext.get('versionName') versionCode rootProject.ext.get('versionCode') testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testBuildType "debug" multiDexEnabled true + } - javaCompileOptions { - annotationProcessorOptions { - arguments = [ "room.schemaLocation": "$rootDir/schema".toString() ] - } - } + room { + schemaDirectory("${rootDir}/schema") } compileOptions { @@ -47,8 +47,8 @@ android { } sourceSets { - main { - androidTest.assets.srcDirs += files("$projectDir/schemas".toString()) + androidTest { + assets.srcDirs += files("$projectDir/schemas".toString()) } } @@ -80,6 +80,7 @@ android { debug { applicationIdSuffix ".debug" signingConfig signingConfigs.debug + //noinspection GroovyConstructorNamedArguments manifestPlaceholders = [ accessToken: "${accessToken}" ] renderscriptDebuggable true pseudoLocalesEnabled false @@ -91,6 +92,7 @@ android { } release { signingConfig signingConfigs.release + //noinspection GroovyConstructorNamedArguments manifestPlaceholders = [ accessToken: "" ] proguardFile "${project.rootDir}/proguard/android.pro" proguardFile "${project.rootDir}/proguard/androidx.pro" @@ -122,73 +124,73 @@ dependencies { api project(path: ':library') // Material Design Components - implementation "com.google.android.material:material:$material_design_version" + implementation libs.material.design // Annotations - implementation "androidx.annotation:annotation:$androidx_annotation_version" + implementation libs.androidx.annotation // Flexbox Layout - implementation "com.google.android.flexbox:flexbox:$flexbox_version" + implementation libs.flexbox // https://developer.android.com/jetpack/androidx/ - implementation "androidx.appcompat:appcompat:$androidx_appcompat_version" - implementation "androidx.core:core-splashscreen:$androidx_splash_version" - implementation "androidx.recyclerview:recyclerview:$androidx_recyclerview_version" - implementation "androidx.preference:preference:$androidx_preference_version" - implementation "androidx.cardview:cardview:$androidx_cardview_version" + implementation libs.androidx.appcompat + implementation libs.androidx.splashscreen + implementation libs.androidx.recyclerview + implementation libs.androidx.preference + implementation libs.androidx.cardview // Navigation - androidTestImplementation "androidx.navigation:navigation-testing:$androidx_navigation_version" - implementation "androidx.navigation:navigation-fragment:$androidx_navigation_version" + androidTestImplementation libs.androidx.navigation.testing + implementation libs.androidx.navigation.fragment // Fragment - androidTestImplementation "androidx.fragment:fragment-testing:$androidx_fragment_version" - implementation "androidx.fragment:fragment:$androidx_fragment_version" + androidTestImplementation libs.androidx.fragment.testing + implementation libs.androidx.fragment // Room Runtime - annotationProcessor "androidx.room:room-compiler:$androidx_room_version" - testImplementation "androidx.room:room-testing:$androidx_room_version" - implementation "androidx.room:room-runtime:$androidx_room_version" + annotationProcessor libs.androidx.room.compiler + testImplementation libs.androidx.room.testing + implementation libs.androidx.room.runtime // Retrofit2 - implementation "com.google.code.gson:gson:$gson_version" - implementation "com.squareup.retrofit2:retrofit:$retrofit_version" - implementation ("com.squareup.retrofit2:converter-gson:$retrofit_version") { + implementation libs.gson + implementation libs.retrofit + implementation (libs.retrofit.gson.converter) { exclude group: "com.google.code.gson", module: "gson" } // https://mvnrepository.com/artifact/org.eclipse.jgit/org.eclipse.jgit - implementation "org.eclipse.jgit:org.eclipse.jgit:$jgit_version" + implementation libs.jgit // https://mvnrepository.com/artifact/org.slf4j/slf4j-simple // api "org.slf4j:slf4j-nop:$slf4j_version" - api "org.slf4j:slf4j-simple:$slf4j_version" + api libs.slf4j // jUnit - testImplementation "junit:junit:$junit_version" + testImplementation libs.junit // Required for connected tests. // https://mvnrepository.com/artifact/androidx.test/monitor - debugImplementation "androidx.test:monitor:$androidx_test_monitor_version" + debugImplementation libs.androidx.test.monitor // https://mvnrepository.com/artifact/androidx.test.ext - androidTestImplementation "androidx.test.ext:junit:$androidx_test_junit_version" + androidTestImplementation libs.androidx.test.junit // https://mvnrepository.com/artifact/androidx.test // https://developer.android.com/jetpack/androidx/releases/test - androidTestImplementation "androidx.test:core:$androidx_test_core_version" - androidTestImplementation "androidx.test:runner:$androidx_test_runner_version" - androidTestImplementation "androidx.test:rules:$androidx_test_rules_version" + androidTestImplementation libs.androidx.test.core + androidTestImplementation libs.androidx.test.runner + androidTestImplementation libs.androidx.test.rules // https://mvnrepository.com/artifact/androidx.test.uiautomator/uiautomator - androidTestImplementation "androidx.test.uiautomator:uiautomator:$androidx_test_uiautomator_version" + androidTestImplementation libs.androidx.test.uiautomator // Espresso - androidTestImplementation "androidx.test.espresso:espresso-core:$androidx_test_espresso_version" + androidTestImplementation libs.androidx.espresso.core + androidTestImplementation libs.androidx.espresso.web // androidTestImplementation "androidx.test.espresso:espresso-contrib:$androidx_test_espresso_version" // androidTestImplementation "androidx.test.espresso:espresso-intents:$androidx_test_espresso_version" // androidTestImplementation "androidx.test.espresso:espresso-accessibility:$androidx_test_espresso_version" - androidTestImplementation "androidx.test.espresso:espresso-web:$androidx_test_espresso_version" // androidTestImplementation "androidx.test.espresso.idling:idling-concurrent:$espresso_version" // The following dependency can be either "implementation" or "androidTestImplementation", diff --git a/settings.gradle b/settings.gradle index 384f0808..feb09e34 100644 --- a/settings.gradle +++ b/settings.gradle @@ -13,6 +13,11 @@ dependencyResolutionManagement { mavenCentral() google() } + versionCatalogs { + libs { + from(files("libs.versions.toml")) + } + } } rootProject.name = "GitHub Client" diff --git a/version.properties b/version.properties index 60e799c1..81ac5417 100644 --- a/version.properties +++ b/version.properties @@ -1,2 +1,2 @@ -versionName = 1.0.2 +versionName = 1.0.3 versionCode = 3