Skip to content

Commit 4662301

Browse files
hunterstichpaulfthomas
authored andcommitted
[Build] Migrated builds to use a version catalog
PiperOrigin-RevId: 738386885
1 parent 71287c6 commit 4662301

File tree

11 files changed

+192
-188
lines changed

11 files changed

+192
-188
lines changed

build.gradle

+7-87
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ buildscript {
44
mavenCentral()
55
}
66
dependencies {
7-
classpath 'com.android.tools.build:gradle:8.7.3'
7+
classpath libs.android.gradle.plugin
88
}
99
}
1010

@@ -21,36 +21,6 @@ ext {
2121
minSdkVersion = 21
2222
targetSdkVersion = 33
2323

24-
androidXVersions = [
25-
activity : '1.8.0',
26-
annotation : '1.2.0',
27-
appCompat : '1.6.1',
28-
cardView : '1.0.0',
29-
constraintlayout : '2.0.1',
30-
coordinatorlayout : '1.1.0',
31-
core : '1.6.0',
32-
drawerlayout : '1.2.0',
33-
experimental : '1.0.0',
34-
fragment : '1.2.5',
35-
lifecycle : '2.0.0',
36-
recyclerView : '1.0.0',
37-
recyclerViewSelection : '1.0.0',
38-
resourceInspectionAnnotation : '1.0.1',
39-
resourceInspectionProcessor : '1.0.1',
40-
transition : '1.5.0',
41-
vectorDrawable : '1.1.0',
42-
viewpager2 : '1.0.0',
43-
dynamicanimation : '1.0.0',
44-
graphicsShapes : '1.0.1',
45-
]
46-
47-
errorproneVersion = '2.15.0'
48-
testRunnerVersion = '1.4.0'
49-
espressoVersion = '3.1.0'
50-
mockitoCoreVersion = '2.25.0'
51-
truthVersion = '0.45'
52-
robolectricVersion = '4.13'
53-
5424
// Enforce the use of prebuilt dependencies in all sub-projects. This is
5525
// required for the doclava dependency.
5626
usePrebuilts = "true"
@@ -83,56 +53,6 @@ private def getTransformedProjectPath(projectPath) {
8353
return result
8454
}
8555

86-
/**
87-
* Return the module dependency for the given compatibility library name.
88-
*/
89-
def compatibility(name) {
90-
switch (name) {
91-
case "activity":
92-
return "androidx.activity:activity:${androidXVersions.activity}"
93-
case "annotation":
94-
return "androidx.annotation:annotation:${androidXVersions.annotation}"
95-
case "appcompat":
96-
return "androidx.appcompat:appcompat:${androidXVersions.appCompat}"
97-
case "cardview":
98-
return "androidx.cardview:cardview:${androidXVersions.cardView}"
99-
case "constraintlayout":
100-
return "androidx.constraintlayout:constraintlayout:${androidXVersions.constraintlayout}"
101-
case "coordinatorlayout":
102-
return "androidx.coordinatorlayout:coordinatorlayout:${androidXVersions.coordinatorlayout}"
103-
case "core":
104-
return "androidx.core:core:${androidXVersions.core}"
105-
case "drawerlayout":
106-
return "androidx.drawerlayout:drawerlayout:${androidXVersions.drawerlayout}"
107-
case "dynamicanimation":
108-
return "androidx.dynamicanimation:dynamicanimation:${androidXVersions.dynamicanimation}"
109-
case "fragment":
110-
return "androidx.fragment:fragment:${androidXVersions.fragment}"
111-
case "lifecycleRuntime":
112-
return "androidx.lifecycle:lifecycle-runtime:${androidXVersions.lifecycle}"
113-
case "recyclerview":
114-
return "androidx.recyclerview:recyclerview:${androidXVersions.recyclerView}"
115-
case "transition":
116-
return "androidx.transition:transition:${androidXVersions.transition}"
117-
case "vectordrawable":
118-
return "androidx.vectordrawable:vectordrawable:${androidXVersions.vectorDrawable}"
119-
case "recyclerViewSelection":
120-
return "androidx.recyclerview:recyclerview-selection:${androidXVersions.recyclerViewSelection}"
121-
case "resourceInspectionAnnotation":
122-
return "androidx.resourceinspection:resourceinspection-annotation:${androidXVersions.resourceInspectionAnnotation}"
123-
case "resourceInspectionProcessor":
124-
return "androidx.resourceinspection:resourceinspection-processor:${androidXVersions.resourceInspectionProcessor}"
125-
case "viewpager2":
126-
return "androidx.viewpager2:viewpager2:${androidXVersions.viewpager2}"
127-
case "graphicsShapes":
128-
return "androidx.graphics:graphics-shapes:${androidXVersions.graphicsShapes}"
129-
case "experimental":
130-
return "androidx.annotation:annotation-experimental:${androidXVersions.experimental}"
131-
default:
132-
throw new IllegalArgumentException("No mapping exists for name: $name.")
133-
}
134-
}
135-
13656
/**
13757
* Return the project dependency for the given project path.
13858
*/
@@ -161,12 +81,12 @@ def getArchivesBaseName(name) {
16181
}
16282

16383
subprojects {
164-
tasks.withType(Test) {
165-
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
166-
forkEvery = 80
167-
maxHeapSize = "2048m"
168-
minHeapSize = "1024m"
169-
}
84+
tasks.withType(Test) {
85+
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
86+
forkEvery = 80
87+
maxHeapSize = "2048m"
88+
minHeapSize = "1024m"
89+
}
17090
}
17191

17292
subprojects {

catalog/build.gradle

+28-29
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,50 @@ apply plugin: 'com.android.application'
33
dependencies {
44

55
// Align kotlin versions
6-
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.22"))
6+
implementation(platform(libs.kotlin.bom))
77

8-
api 'com.google.dagger:dagger:2.51.1'
9-
annotationProcessor 'com.google.dagger:dagger-compiler:2.51.1'
8+
api libs.dagger
9+
annotationProcessor libs.dagger.compiler
1010

11-
api 'com.google.dagger:dagger-android:2.51.1'
12-
api 'com.google.dagger:dagger-android-support:2.51.1'
13-
annotationProcessor 'com.google.dagger:dagger-android-processor:2.51.1'
11+
api libs.dagger.android
12+
api libs.dagger.android.support
13+
annotationProcessor libs.dagger.android.processor
1414

15-
api 'androidx.multidex:multidex:2.0.1'
16-
api 'androidx.constraintlayout:constraintlayout:2.1.0'
17-
api 'androidx.gridlayout:gridlayout:1.0.0'
18-
api "androidx.multidex:multidex:2.0.1"
19-
api "androidx.recyclerview:recyclerview:1.2.1"
20-
api 'androidx.window:window:1.0.0-beta04'
21-
api "androidx.window:window-java:1.0.0-beta04"
22-
api "androidx.preference:preference:1.1.1"
15+
api libs.androidx.multidex
16+
api libs.androidx.constraintlayout
17+
api libs.androidx.gridlayout
18+
api libs.androidx.recyclerview
19+
api libs.androidx.window
20+
api libs.androidx.window.java
21+
api libs.androidx.preference
2322

24-
api 'com.google.guava:guava:33.3.1-android'
23+
api libs.guava
2524
modules {
2625
module("com.google.guava:listenablefuture") {
2726
replacedBy("com.google.guava:guava", "listenablefuture is part of guava")
2827
}
2928
}
3029

31-
api 'com.github.bumptech.glide:glide:4.16.0'
30+
api libs.glide
3231

3332
api project(':lib')
3433

35-
api compatibility("recyclerViewSelection")
34+
api libs.androidx.recyclerview.selection
3635

37-
implementation "com.google.errorprone:error_prone_annotations:${errorproneVersion}"
36+
implementation libs.errorprone.annotations
3837

39-
androidTestImplementation "androidx.test:core:${project.rootProject.ext.testRunnerVersion}"
40-
androidTestImplementation "androidx.test:runner:${project.rootProject.ext.testRunnerVersion}"
41-
androidTestImplementation "androidx.test:rules:${project.rootProject.ext.testRunnerVersion}"
42-
androidTestImplementation "androidx.test.espresso:espresso-core:${project.rootProject.ext.espressoVersion}"
43-
androidTestImplementation "androidx.test.espresso:espresso-contrib:${project.rootProject.ext.espressoVersion}"
38+
androidTestImplementation libs.androidx.test.core
39+
androidTestImplementation libs.androidx.test.runner
40+
androidTestImplementation libs.androidx.test.rules
41+
androidTestImplementation libs.androidx.espresso.core
42+
androidTestImplementation libs.androidx.espresso.contrib
4443

45-
testImplementation "androidx.test:core:${project.rootProject.ext.testRunnerVersion}"
46-
testImplementation "androidx.test:runner:${project.rootProject.ext.testRunnerVersion}"
47-
testImplementation "junit:junit:4.13.2"
48-
testImplementation "com.google.truth:truth:${project.rootProject.ext.truthVersion}"
49-
testImplementation "org.mockito:mockito-core:${project.rootProject.ext.mockitoCoreVersion}"
50-
testImplementation "org.robolectric:robolectric:${project.rootProject.ext.robolectricVersion}"
44+
testImplementation libs.androidx.test.core
45+
testImplementation libs.androidx.test.runner
46+
testImplementation libs.junit
47+
testImplementation libs.truth
48+
testImplementation libs.mockito.core
49+
testImplementation libs.robolectric
5150
}
5251

5352
def srcDirs = [

gradle/libs.versions.toml

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
[versions]
2+
androidGradlePlugin = "8.7.3"
3+
4+
# Main library dependencies.
5+
# Versions defined for :lib are required to follow library versioning - stable
6+
# releases of the library can only use stable dependencies
7+
androidXActivity = "1.8.0"
8+
androidXAnnotation = "1.2.0"
9+
androidXAnnotationExperimental = "1.0.0"
10+
androidXAppCompat = "1.6.1"
11+
androidXCardView = "1.0.0"
12+
androidXConstraintLayout = "2.1.0"
13+
androidXCoordinatorLayout = "1.1.0"
14+
androidXCore = "1.6.0"
15+
androidXDrawerLayout = "1.1.1"
16+
androidXDynamicAnimation = "1.0.0"
17+
androidXEspresso = "3.1.0"
18+
androidXFragment = "1.2.5"
19+
androidXGridLayout = "1.0.0"
20+
androidXGraphicsShapes = "1.0.1"
21+
androidXLifecycle = "2.0.0"
22+
androidXMultidex = "2.0.1"
23+
androidXPreference = "1.1.1"
24+
androidXRecyclerView = "1.2.1"
25+
androidXRecyclerViewSelection = "1.0.0"
26+
androidXResourceInspectionAnnotation = "1.0.1"
27+
androidXResourceInspectionProcessor = "1.0.1"
28+
androidXTestCore = "1.4.0"
29+
androidXTransition = "1.5.0"
30+
androidXVectorDrawable = "1.1.0"
31+
androidXViewPager2 = "1.0.0"
32+
androidXWindow = "1.0.0"
33+
dagger = "2.51.1"
34+
dexmaker = "1.2"
35+
errorProneAnnotations = "2.15.0"
36+
glide = "4.16.0"
37+
guava = "33.3.1-android"
38+
junit = "4.13.2"
39+
kotlinBom = "1.8.22"
40+
mockitoCore = "2.25.0"
41+
robolectric = "4.13"
42+
truth = "0.45"
43+
44+
[libraries]
45+
android-gradle-plugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" }
46+
androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "androidXActivity" }
47+
androidx-annotation = { group = "androidx.annotation", name = "annotation", version.ref = "androidXAnnotation" }
48+
androidx-annotation-experimental = { group = "androidx.annotation", name = "annotation-experimental", version.ref = "androidXAnnotationExperimental" }
49+
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidXAppCompat" }
50+
androidx-cardview = { group = "androidx.cardview", name = "cardview", version.ref = "androidXCardView" }
51+
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "androidXConstraintLayout" }
52+
androidx-coordinatorlayout = { group = "androidx.coordinatorlayout", name = "coordinatorlayout", version.ref = "androidXCoordinatorLayout" }
53+
androidx-core = { group = "androidx.core", name = "core", version.ref = "androidXCore" }
54+
androidx-drawerlayout = { group = "androidx.drawerlayout", name = "drawerlayout", version.ref = "androidXDrawerLayout" }
55+
androidx-dynamicanimation = { group = "androidx.dynamicanimation", name = "dynamicanimation", version.ref = "androidXDynamicAnimation" }
56+
androidx-fragment = { group = "androidx.fragment", name = "fragment", version.ref = "androidXFragment" }
57+
androidx-gridlayout = { group = "androidx.gridlayout", name = "gridlayout", version.ref = "androidXGridLayout" }
58+
androidx-lifecycle-runtime = { group = "androidx.lifecycle", name = "lifecycle-runtime", version.ref = "androidXLifecycle" }
59+
androidx-multidex = { group = "androidx.multidex", name= "multidex", version.ref = "androidXMultidex" }
60+
androidx-preference = { group = "androidx.preference", name = "preference", version.ref = "androidXPreference" }
61+
androidx-recyclerview = { group = "androidx.recyclerview", name = "recyclerview", version.ref = "androidXRecyclerView" }
62+
androidx-transition = { group = "androidx.transition", name = "transition", version.ref = "androidXTransition" }
63+
androidx-vectordrawable = { group = "androidx.vectordrawable", name= "vectordrawable", version.ref = "androidXVectorDrawable" }
64+
androidx-recyclerview-selection = { group = "androidx.recyclerview", name = "recyclerview-selection", version.ref = "androidXRecyclerViewSelection" }
65+
androidx-resourceinspection-annotation = { group = "androidx.resourceinspection", name = "resourceinspection-annotation", version.ref = "androidXResourceInspectionAnnotation" }
66+
androidx-resourceinspection-processor = { group = "androidx.resourceinspection", name = "resourceinspection-processor", version.ref = "androidXResourceInspectionProcessor" }
67+
androidx-viewpager2 = { group = "androidx.viewpager2", name = "viewpager2", version.ref = "androidXViewPager2" }
68+
androidx-graphics-shapes = { group = "androidx.graphics", name = "graphics-shapes", version.ref = "androidXGraphicsShapes" }
69+
androidx-espresso-accessibility = { group = "androidx.test.espresso", name = "espresso-accessibility", version.ref = "androidXEspresso" }
70+
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "androidXEspresso" }
71+
androidx-espresso-contrib = { group = "androidx.test.espresso", name = "espresso-contrib", version.ref = "androidXEspresso" }
72+
androidx-test-core = { group = "androidx.test", name = "core", version.ref = "androidXTestCore" }
73+
androidx-test-runner = { group = "androidx.test", name = "runner", version.ref = "androidXTestCore" }
74+
androidx-test-rules = { group = "androidx.test", name = "rules", version.ref = "androidXTestCore" }
75+
androidx-window = { group = "androidx.window", name = "window", version.ref = "androidXWindow" }
76+
androidx-window-java = { group = "androidx.window", name = "window-java", version.ref = "androidXWindow" }
77+
dagger = { group = "com.google.dagger", name = "dagger", version.ref = "dagger" }
78+
dagger-android = { group = "com.google.dagger", name = "dagger-android", version.ref = "dagger" }
79+
dagger-android-processor = { group = "com.google.dagger", name = "dagger-android-processor", version.ref = "dagger" }
80+
dagger-android-support = { group = "com.google.dagger", name = "dagger-android-support", version.ref = "dagger" }
81+
dagger-compiler = { group = "com.google.dagger", name = "dagger-compiler", version.ref = "dagger" }
82+
dexmaker = { group = "com.google.dexmaker", name = "dexmaker", version.ref = "dexmaker" }
83+
dexmaker-mokito = { group = "com.google.dexmaker", name = "dexmaker-mockito", version.ref = "dexmaker" }
84+
errorprone-annotations = { group = "com.google.errorprone", name = "error_prone_annotations", version.ref = "errorProneAnnotations" }
85+
glide = { group = "com.github.bumptech.glide", name = "glide", version.ref = "glide" }
86+
guava = { group = "com.google.guava", name = "guava", version.ref = "guava" }
87+
junit = { group = "junit", name = "junit", version.ref = "junit" }
88+
kotlin-bom = { group = "org.jetbrains.kotlin", name = "kotlin-bom", version.ref = "kotlinBom" }
89+
mockito-core = { group = "org.mockito", name = "mockito-core", version.ref = "mockitoCore" }
90+
robolectric = { group = "org.robolectric", name = "robolectric", version.ref = "robolectric" }
91+
truth = { group = "com.google.truth", name = "truth", version.ref = "truth" }

lib/build.gradle

+29-30
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,37 @@ apply plugin: 'maven-publish'
66
version = mdcLibraryVersion
77

88
dependencies {
9-
api compatibility("activity")
10-
api compatibility("annotation")
11-
api compatibility("appcompat")
12-
api compatibility("cardview")
13-
api compatibility("coordinatorlayout")
14-
api compatibility("constraintlayout")
15-
api compatibility("core")
16-
api compatibility("drawerlayout")
17-
api compatibility("dynamicanimation")
18-
api compatibility("experimental")
19-
api compatibility("fragment")
20-
api compatibility("lifecycleRuntime")
21-
api compatibility("recyclerview")
22-
api compatibility("resourceInspectionAnnotation")
23-
api compatibility("transition")
24-
api compatibility("vectordrawable")
25-
api compatibility("viewpager2")
26-
api compatibility("graphicsShapes")
27-
28-
annotationProcessor compatibility("resourceInspectionProcessor")
9+
api libs.androidx.activity
10+
api libs.androidx.annotation
11+
api libs.androidx.annotation.experimental
12+
api libs.androidx.appcompat
13+
api libs.androidx.cardview
14+
api libs.androidx.coordinatorlayout
15+
api libs.androidx.constraintlayout
16+
api libs.androidx.core
17+
api libs.androidx.drawerlayout
18+
api libs.androidx.dynamicanimation
19+
api libs.androidx.fragment
20+
api libs.androidx.lifecycle.runtime
21+
api libs.androidx.recyclerview
22+
api libs.androidx.resourceinspection.annotation
23+
api libs.androidx.transition
24+
api libs.androidx.vectordrawable
25+
api libs.androidx.viewpager2
26+
api libs.androidx.graphics.shapes
27+
28+
annotationProcessor libs.androidx.resourceinspection.processor
2929

3030
// Align kotlin versions
31-
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.22"))
32-
33-
implementation "com.google.errorprone:error_prone_annotations:${errorproneVersion}"
34-
35-
testImplementation "androidx.test:core:${testRunnerVersion}"
36-
testImplementation "androidx.test:runner:${testRunnerVersion}"
37-
testImplementation "junit:junit:4.13.2"
38-
testImplementation "com.google.truth:truth:${truthVersion}"
39-
testImplementation "org.mockito:mockito-core:${mockitoCoreVersion}"
40-
testImplementation "org.robolectric:robolectric:${robolectricVersion}"
31+
implementation(platform(libs.kotlin.bom))
32+
33+
implementation libs.errorprone.annotations
34+
testImplementation libs.androidx.test.core
35+
testImplementation libs.androidx.test.runner
36+
testImplementation libs.junit
37+
testImplementation libs.truth
38+
testImplementation libs.mockito.core
39+
testImplementation libs.robolectric
4140
}
4241

4342
def srcDirs = [

testing/java/com/google/android/material/testapp/animation/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
apply plugin: 'com.android.application'
1818

1919
dependencies {
20-
api compatibility("appcompat")
21-
api compatibility("core")
20+
api libs.androidx.appcompat
21+
api libs.androidx.core
2222

2323
api project(fromPath("lib"))
2424
api project(fromPath("testing/java/com/google/android/material/testapp/base"))
2525

26-
api 'androidx.multidex:multidex:2.0.1'
26+
api libs.androidx.multidex
2727
}
2828

2929
android {

testing/java/com/google/android/material/testapp/base/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
apply plugin: 'com.android.library'
1818

1919
dependencies {
20-
api compatibility("appcompat")
21-
api compatibility("core")
22-
api compatibility("fragment")
20+
api libs.androidx.appcompat
21+
api libs.androidx.core
22+
api libs.androidx.fragment
2323
}
2424

2525
android {

0 commit comments

Comments
 (0)