-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathbuild.gradle
215 lines (184 loc) · 5.58 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
buildscript {
ext {
compose_version = '1.7.0-alpha02'
compose_compiler_version = '1.5.9'
compose_tooling = '1.2.0'
customView = '1.2.0-alpha02'
customViewPooling = '1.0.0'
kotlin_version = '1.9.22'
room = "2.6.1"
KAHelpers = '3.2.2'
moshi = "1.15.1"
daggerVersion = '2.50'
hiltJetpackVersion = '1.0.0'
retrofit = "2.9.0"
accompanist = "0.30.1"
lifecycle = '2.8.0-alpha01'
composed = '0.0.17'
paging_compose = '3.3.0-alpha03'
paging_runtime = '3.2.0-alpha01'
navigation = '2.7.7'
activity = "1.8.2"
hilt_navigation_compose = "1.1.0"
jsoup = "1.17.2"
data_store = "1.0.0"
coreKTX = "1.12.0"
crashy = "1.2.0"
coil = "2.6.0"
work_version = "2.9.0"
hilt_work = "1.1.0"
//compilation
compileVersion = 32
minVersion = 24
//updatable
verCode = 4
verName = "1.2.0"
testRunner = "androidx.test.runner.AndroidJUnitRunner"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.google.dagger:hilt-android-gradle-plugin:$daggerVersion"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
static def excludeParentFoldersFor(project) {
def name = ""
def allProjects = project.getAllprojects()
if (allProjects.size() > 1) {
name = allProjects.first().name
}
return name
}
subprojects {
switch (it.name) {
case "app":
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'dagger.hilt.android.plugin'
applyAndroid(it)
break
//ignore parent folders
case excludeParentFoldersFor(it):
break
// kotlin/java only modules
case ["serverconstants", "generalbook", "bookdetailsmodel", "bookmodel", "scrapermodel"]:
apply plugin: 'java-library'
apply plugin: 'kotlin'
applyKotlinModule(it)
break
default:
//setup gradle for libraries
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
applyAndroid(it)
break
}
}
def enableCompose(project) {
project.android {
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion compose_compiler_version
}
}
}
def enableBuildConfig(project) {
project.android {
buildFeatures {
buildConfig = true
}
}
}
def applyKotlinModule(project) {
project.java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
def applyAndroid(project) {
project.android {
compileSdkVersion compileVersion
defaultConfig {
minSdkVersion minVersion
targetSdkVersion compileVersion
versionCode verCode
versionName verName
testInstrumentationRunner testRunner
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs += "-opt-in"
freeCompilerArgs += "-Xjvm-default=all"
}
testOptions.unitTests {
includeAndroidResources = true
}
buildFeatures {
aidl = false
renderScript = false
resValues = false
shaders = false
}
}
}
def applyRoomDeps(project) {
project.dependencies {
//room
implementation "androidx.room:room-ktx:$room"
implementation "androidx.room:room-paging:$room"
kapt "androidx.room:room-compiler:$room"
}
}
def applyHiltDeps(project) {
project.dependencies {
//hilt
implementation "com.google.dagger:hilt-android:$daggerVersion"
kapt "com.google.dagger:hilt-android-compiler:$daggerVersion"
}
}
def applyComposeUIDeps(project) {
enableCompose(project)
project.dependencies {
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.runtime:runtime:$compose_version"
implementation "androidx.compose.compiler:compiler:$compose_compiler_version"
implementation "androidx.compose.foundation:foundation:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation "androidx.lifecycle:lifecycle-runtime-compose:$lifecycle"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.customview:customview:$customView"
debugImplementation "androidx.customview:customview-poolingcontainer:$customViewPooling"
}
}
def applyMoshiDeps(project) {
project.dependencies {
implementation "com.squareup.moshi:moshi:$moshi"
kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshi"
}
}
def applyCoilDep(project) {
project.dependencies {
implementation "io.coil-kt:coil-compose:$coil"
}
}
def applyWorkerDeps(project) {
project.dependencies {
implementation "androidx.work:work-runtime-ktx:$work_version"
implementation "androidx.hilt:hilt-work:$hilt_work"
kapt "androidx.hilt:hilt-compiler:$hilt_work"
}
}