Skip to content

Commit 20f2317

Browse files
committed
migrated to version catalog.
1 parent 7f0d8db commit 20f2317

File tree

6 files changed

+134
-98
lines changed

6 files changed

+134
-98
lines changed

build.gradle

+4-40
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,8 @@
11
// root build.gradle
2-
buildscript {
3-
ext {
4-
android_gradle_plugin_version = '8.3.1'
5-
material_design_version = '1.11.0'
6-
kotlin_version = '1.9.21'
7-
retrofit_version = '2.9.0'
8-
gson_version = '2.10.1'
9-
junit_version = '4.13.2'
10-
flexbox_version = '3.0.0'
11-
12-
// DirCacheCheckout.java uses InputStream.transferTo() since 6.3; no such method on Android.
13-
jgit_version = '6.2.0.202206071550-r' // instead of 6.5.0.202303070854-r
14-
slf4j_version = '2.0.9'
15-
16-
androidx_appcompat_version = '1.6.1'
17-
androidx_annotation_version = '1.6.0'
18-
androidx_fragment_version = '1.6.2'
19-
androidx_navigation_version = '2.7.7'
20-
androidx_room_version = '2.6.1'
21-
androidx_splash_version = '1.0.1'
22-
androidx_recyclerview_version = '1.3.2'
23-
androidx_preference_version = '1.2.1'
24-
androidx_cardview_version = '1.0.0'
25-
26-
androidx_test_junit_version = '1.1.5'
27-
androidx_test_core_version = '1.5.0'
28-
androidx_test_monitor_version = '1.6.1'
29-
androidx_test_runner_version = '1.5.2'
30-
androidx_test_rules_version = '1.5.0'
31-
androidx_test_uiautomator_version = '2.3.0'
32-
androidx_test_espresso_version = '3.5.1'
33-
}
34-
}
35-
362
plugins {
37-
id 'com.android.application' version "$android_gradle_plugin_version" apply false
38-
id 'com.android.library' version "$android_gradle_plugin_version" apply false
39-
id 'androidx.navigation.safeargs' version "$androidx_navigation_version" apply false
3+
alias(libs.plugins.android.application) apply false
4+
alias(libs.plugins.android.library) apply false
5+
alias(libs.plugins.androidx.navigation.safeargs) apply false
406
}
417

428
/** Version Settings, loaded from file `version.properties` */
@@ -74,9 +40,7 @@ allprojects {
7440
def requested = details.requested
7541
if (requested.group == 'org.jetbrains.kotlin') {
7642
List<String> list = ['kotlin-stdlib', 'kotlin-stdlib-jdk7', 'kotlin-stdlib-jdk8', 'kotlin-stdlib-common']
77-
if (list.contains(requested.name)) {
78-
details.useVersion "$kotlin_version"
79-
}
43+
if (list.contains(requested.name)) { details.useVersion libs.versions.kotlin.get() }
8044
}
8145
}
8246
}

library/build.gradle

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
2-
id 'com.android.library'
2+
alias(libs.plugins.android.library)
3+
alias(libs.plugins.androidx.room)
34
id 'maven-publish'
45
}
56

@@ -16,20 +17,19 @@ android {
1617
targetSdk 34
1718
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1819
consumerProguardFile "${project.rootDir}/proguard/consumer.pro"
19-
javaCompileOptions {
20-
annotationProcessorOptions {
21-
arguments = [ "room.schemaLocation": "$rootDir/schema".toString() ]
22-
}
23-
}
2420
}
2521

26-
sourceSets.main.java.srcDirs = [ "src/main/java" ]
22+
room {
23+
schemaDirectory("${rootDir}/schema")
24+
}
2725

2826
compileOptions {
2927
sourceCompatibility JavaVersion.VERSION_17
3028
targetCompatibility JavaVersion.VERSION_17
3129
}
3230

31+
sourceSets.main.java.srcDirs = [ "src/main/java" ]
32+
3333
buildFeatures {
3434
buildConfig true
3535
dataBinding true
@@ -65,31 +65,31 @@ android {
6565
dependencies {
6666

6767
// Material Design Components
68-
implementation "com.google.android.material:material:$material_design_version"
68+
implementation libs.material.design
6969

7070
// Annotations
71-
implementation "androidx.annotation:annotation:$androidx_annotation_version"
71+
implementation libs.androidx.annotation
7272

7373
// App Compat
74-
implementation "androidx.appcompat:appcompat:$androidx_appcompat_version"
74+
implementation libs.androidx.appcompat
7575

7676
// Data-Binding Runtime
77-
implementation "androidx.databinding:databinding-runtime:$android_gradle_plugin_version"
77+
implementation libs.androidx.databinding
7878

7979
// Room Runtime
80-
annotationProcessor "androidx.room:room-compiler:$androidx_room_version"
81-
testImplementation "androidx.room:room-testing:$androidx_room_version"
82-
implementation "androidx.room:room-runtime:$androidx_room_version"
80+
annotationProcessor libs.androidx.room.compiler
81+
testImplementation libs.androidx.room.testing
82+
implementation libs.androidx.room.runtime
8383

8484
// Retrofit2
85-
implementation "com.google.code.gson:gson:$gson_version"
86-
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
87-
implementation ("com.squareup.retrofit2:converter-gson:$retrofit_version") {
85+
implementation libs.gson
86+
implementation libs.retrofit
87+
implementation (libs.retrofit.gson.converter) {
8888
exclude group: "com.google.code.gson", module: "gson"
8989
}
9090

91-
testImplementation "junit:junit:$junit_version"
92-
androidTestImplementation "androidx.test.ext:junit:$androidx_test_junit_version"
91+
testImplementation libs.junit
92+
androidTestImplementation libs.androidx.test.junit
9393
}
9494

9595
tasks.register('javadoc', Javadoc) {

libs.versions.toml

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
[versions]
2+
android_gradle_plugin = '8.3.1'
3+
material_design = '1.11.0'
4+
kotlin = '1.9.22'
5+
retrofit = '2.9.0'
6+
gson = '2.10.1'
7+
junit = '4.13.2'
8+
flexbox = '3.0.0'
9+
jgit = '6.2.0.202206071550-r'
10+
slf4j = '2.0.9'
11+
androidx_appcompat = '1.6.1'
12+
androidx_annotation = '1.7.1'
13+
androidx_navigation = '2.7.7'
14+
androidx_fragment = '1.6.2'
15+
androidx_recyclerview = '1.3.2'
16+
androidx_cardview = '1.0.0'
17+
androidx_preference = '1.2.1'
18+
androidx_room = '2.6.1'
19+
androidx_splashscreen = '1.0.1'
20+
androidx_test_junit = '1.1.5'
21+
androidx_test_core = '1.5.0'
22+
androidx_test_rules = '1.5.0'
23+
androidx_test_runner = '1.5.2'
24+
androidx_test_monitor = '1.6.1'
25+
androidx_test_uiautomator = '2.3.0'
26+
androidx_test_espresso = '3.5.1'
27+
28+
[plugins]
29+
android_application = { id = "com.android.application", version.ref = "android_gradle_plugin" }
30+
android_library = { id = "com.android.library", version.ref = "android_gradle_plugin" }
31+
androidx_navigation_safeargs = { id = "androidx.navigation.safeargs", version.ref = "androidx_navigation" }
32+
androidx_room = { id = "androidx.room", version.ref = "androidx_room" }
33+
34+
[libraries]
35+
material_design = { module = "com.google.android.material:material", version.ref = "material_design" }
36+
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
37+
junit = { module = "junit:junit", version.ref = "junit" }
38+
flexbox = { module = "com.google.android.flexbox:flexbox", version.ref = "flexbox" }
39+
retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }
40+
retrofit_gson_converter = { module = "com.squareup.retrofit2:converter-gson", version.ref = "retrofit" }
41+
# DirCacheCheckout.java uses InputStream.transferTo() since 6.3; no such method on Android.
42+
jgit = { module = "org.eclipse.jgit:org.eclipse.jgit", version.ref = "jgit" }
43+
slf4j = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j" }
44+
androidx_databinding = { module = "androidx.databinding:databinding-runtime", version.ref = "android_gradle_plugin" }
45+
androidx_appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx_appcompat" }
46+
androidx_annotation = { module = "androidx.annotation:annotation", version.ref = "androidx_annotation" }
47+
androidx_fragment = { module = "androidx.fragment:fragment", version.ref = "androidx_fragment" }
48+
androidx_fragment_testing = { module = "androidx.fragment:fragment-testing", version.ref = "androidx_fragment" }
49+
androidx_recyclerview = { module = "androidx.recyclerview:recyclerview", version.ref = "androidx_recyclerview" }
50+
androidx_cardview = { module = "androidx.cardview:cardview", version.ref = "androidx_cardview" }
51+
androidx_preference = { module = "androidx.preference:preference", version.ref = "androidx_preference" }
52+
androidx_navigation_testing = { module = "androidx.navigation:navigation-testing", version.ref = "androidx_navigation" }
53+
androidx_navigation_fragment = { module = "androidx.navigation:navigation-fragment", version.ref = "androidx_navigation" }
54+
androidx_room_testing = { module = "androidx.room:room-testing", version.ref = "androidx_room" }
55+
androidx_room_compiler = { module = "androidx.room:room-compiler", version.ref = "androidx_room" }
56+
androidx_room_runtime = { module = "androidx.room:room-runtime", version.ref = "androidx_room" }
57+
androidx_splashscreen = { module = "androidx.core:core-splashscreen", version.ref = "androidx_splashscreen" }
58+
androidx_test_monitor = { module = "androidx.test:monitor", version.ref = "androidx_test_monitor" }
59+
androidx_test_junit = { module = "androidx.test.ext:junit", version.ref = "androidx_test_junit" }
60+
androidx_test_core = { module = "androidx.test:core", version.ref = "androidx_test_core" }
61+
androidx_test_rules = { module = "androidx.test:rules", version.ref = "androidx_test_rules" }
62+
androidx_test_runner = { module = "androidx.test:runner", version.ref = "androidx_test_runner" }
63+
androidx_test_uiautomator = { module = "androidx.test.uiautomator:uiautomator", version.ref = "androidx_test_uiautomator" }
64+
androidx_espresso_core = { module = "androidx.test.espresso:espresso-core", version.ref = "androidx_test_espresso" }
65+
androidx_espresso_web = { module = "androidx.test.espresso:espresso-web", version.ref = "androidx_test_espresso" }

mobile/build.gradle

+40-38
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// :mobile build.gradle
22
plugins {
3-
id "com.android.application"
4-
id "androidx.navigation.safeargs"
3+
alias(libs.plugins.android.application)
4+
alias(libs.plugins.androidx.navigation.safeargs)
5+
alias(libs.plugins.androidx.room)
56
}
67

78
/** Load API access-token from file `token.properties` */
@@ -27,18 +28,17 @@ android {
2728
minSdk 22
2829
targetSdk 34
2930
applicationId 'io.syslogic.github'
31+
//noinspection GroovyConstructorNamedArguments
3032
manifestPlaceholders = [ accessToken: "" ]
3133
versionName rootProject.ext.get('versionName')
3234
versionCode rootProject.ext.get('versionCode')
3335
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3436
testBuildType "debug"
3537
multiDexEnabled true
38+
}
3639

37-
javaCompileOptions {
38-
annotationProcessorOptions {
39-
arguments = [ "room.schemaLocation": "$rootDir/schema".toString() ]
40-
}
41-
}
40+
room {
41+
schemaDirectory("${rootDir}/schema")
4242
}
4343

4444
compileOptions {
@@ -47,8 +47,8 @@ android {
4747
}
4848

4949
sourceSets {
50-
main {
51-
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
50+
androidTest {
51+
assets.srcDirs += files("$projectDir/schemas".toString())
5252
}
5353
}
5454

@@ -80,6 +80,7 @@ android {
8080
debug {
8181
applicationIdSuffix ".debug"
8282
signingConfig signingConfigs.debug
83+
//noinspection GroovyConstructorNamedArguments
8384
manifestPlaceholders = [ accessToken: "${accessToken}" ]
8485
renderscriptDebuggable true
8586
pseudoLocalesEnabled false
@@ -91,6 +92,7 @@ android {
9192
}
9293
release {
9394
signingConfig signingConfigs.release
95+
//noinspection GroovyConstructorNamedArguments
9496
manifestPlaceholders = [ accessToken: "" ]
9597
proguardFile "${project.rootDir}/proguard/android.pro"
9698
proguardFile "${project.rootDir}/proguard/androidx.pro"
@@ -122,73 +124,73 @@ dependencies {
122124
api project(path: ':library')
123125

124126
// Material Design Components
125-
implementation "com.google.android.material:material:$material_design_version"
127+
implementation libs.material.design
126128

127129
// Annotations
128-
implementation "androidx.annotation:annotation:$androidx_annotation_version"
130+
implementation libs.androidx.annotation
129131

130132
// Flexbox Layout
131-
implementation "com.google.android.flexbox:flexbox:$flexbox_version"
133+
implementation libs.flexbox
132134

133135
// https://developer.android.com/jetpack/androidx/
134-
implementation "androidx.appcompat:appcompat:$androidx_appcompat_version"
135-
implementation "androidx.core:core-splashscreen:$androidx_splash_version"
136-
implementation "androidx.recyclerview:recyclerview:$androidx_recyclerview_version"
137-
implementation "androidx.preference:preference:$androidx_preference_version"
138-
implementation "androidx.cardview:cardview:$androidx_cardview_version"
136+
implementation libs.androidx.appcompat
137+
implementation libs.androidx.splashscreen
138+
implementation libs.androidx.recyclerview
139+
implementation libs.androidx.preference
140+
implementation libs.androidx.cardview
139141

140142
// Navigation
141-
androidTestImplementation "androidx.navigation:navigation-testing:$androidx_navigation_version"
142-
implementation "androidx.navigation:navigation-fragment:$androidx_navigation_version"
143+
androidTestImplementation libs.androidx.navigation.testing
144+
implementation libs.androidx.navigation.fragment
143145

144146
// Fragment
145-
androidTestImplementation "androidx.fragment:fragment-testing:$androidx_fragment_version"
146-
implementation "androidx.fragment:fragment:$androidx_fragment_version"
147+
androidTestImplementation libs.androidx.fragment.testing
148+
implementation libs.androidx.fragment
147149

148150
// Room Runtime
149-
annotationProcessor "androidx.room:room-compiler:$androidx_room_version"
150-
testImplementation "androidx.room:room-testing:$androidx_room_version"
151-
implementation "androidx.room:room-runtime:$androidx_room_version"
151+
annotationProcessor libs.androidx.room.compiler
152+
testImplementation libs.androidx.room.testing
153+
implementation libs.androidx.room.runtime
152154

153155
// Retrofit2
154-
implementation "com.google.code.gson:gson:$gson_version"
155-
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
156-
implementation ("com.squareup.retrofit2:converter-gson:$retrofit_version") {
156+
implementation libs.gson
157+
implementation libs.retrofit
158+
implementation (libs.retrofit.gson.converter) {
157159
exclude group: "com.google.code.gson", module: "gson"
158160
}
159161

160162
// https://mvnrepository.com/artifact/org.eclipse.jgit/org.eclipse.jgit
161-
implementation "org.eclipse.jgit:org.eclipse.jgit:$jgit_version"
163+
implementation libs.jgit
162164

163165
// https://mvnrepository.com/artifact/org.slf4j/slf4j-simple
164166
// api "org.slf4j:slf4j-nop:$slf4j_version"
165-
api "org.slf4j:slf4j-simple:$slf4j_version"
167+
api libs.slf4j
166168

167169
// jUnit
168-
testImplementation "junit:junit:$junit_version"
170+
testImplementation libs.junit
169171

170172
// Required for connected tests.
171173
// https://mvnrepository.com/artifact/androidx.test/monitor
172-
debugImplementation "androidx.test:monitor:$androidx_test_monitor_version"
174+
debugImplementation libs.androidx.test.monitor
173175

174176
// https://mvnrepository.com/artifact/androidx.test.ext
175-
androidTestImplementation "androidx.test.ext:junit:$androidx_test_junit_version"
177+
androidTestImplementation libs.androidx.test.junit
176178

177179
// https://mvnrepository.com/artifact/androidx.test
178180
// https://developer.android.com/jetpack/androidx/releases/test
179-
androidTestImplementation "androidx.test:core:$androidx_test_core_version"
180-
androidTestImplementation "androidx.test:runner:$androidx_test_runner_version"
181-
androidTestImplementation "androidx.test:rules:$androidx_test_rules_version"
181+
androidTestImplementation libs.androidx.test.core
182+
androidTestImplementation libs.androidx.test.runner
183+
androidTestImplementation libs.androidx.test.rules
182184

183185
// https://mvnrepository.com/artifact/androidx.test.uiautomator/uiautomator
184-
androidTestImplementation "androidx.test.uiautomator:uiautomator:$androidx_test_uiautomator_version"
186+
androidTestImplementation libs.androidx.test.uiautomator
185187

186188
// Espresso
187-
androidTestImplementation "androidx.test.espresso:espresso-core:$androidx_test_espresso_version"
189+
androidTestImplementation libs.androidx.espresso.core
190+
androidTestImplementation libs.androidx.espresso.web
188191
// androidTestImplementation "androidx.test.espresso:espresso-contrib:$androidx_test_espresso_version"
189192
// androidTestImplementation "androidx.test.espresso:espresso-intents:$androidx_test_espresso_version"
190193
// androidTestImplementation "androidx.test.espresso:espresso-accessibility:$androidx_test_espresso_version"
191-
androidTestImplementation "androidx.test.espresso:espresso-web:$androidx_test_espresso_version"
192194
// androidTestImplementation "androidx.test.espresso.idling:idling-concurrent:$espresso_version"
193195

194196
// The following dependency can be either "implementation" or "androidTestImplementation",

settings.gradle

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ dependencyResolutionManagement {
1313
mavenCentral()
1414
google()
1515
}
16+
versionCatalogs {
17+
libs {
18+
from(files("libs.versions.toml"))
19+
}
20+
}
1621
}
1722

1823
rootProject.name = "GitHub Client"

version.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
versionName = 1.0.2
1+
versionName = 1.0.3
22
versionCode = 3

0 commit comments

Comments
 (0)