generated from SmashKs/JurassicPark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
209 lines (197 loc) · 7.99 KB
/
build.gradle.kts
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
/*
* MIT License
*
* Copyright (c) 2019 SmashKs
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Top-level build file where you can add configuration options common to all sub-projects/modules.
import com.android.build.gradle.BaseExtension
import com.android.build.gradle.internal.dsl.DefaultConfig
import org.jetbrains.kotlin.gradle.plugin.KaptExtension
buildscript {
repositories {
google()
jcenter()
maven {
url = uri("https://dl.bintray.com/kotlin/kotlin-eap")
url = uri("https://maven.fabric.io/public")
}
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.1")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath(config.GradleDependency.KOTLIN)
classpath(config.GradleDependency.SAFE_ARGS)
classpath(config.GradleDependency.GOOGLE_SERVICE)
// classpath "org.jacoco:org.jacoco.core:0.8.4"
// classpath("io.fabric.tools:gradle:1.31.1")
}
}
plugins {
id(config.GradleDependency.DETEKT).version(config.GradleDependency.Version.DETEKT)
id(config.GradleDependency.GRADLE_VERSION_UPDATER).version(config.GradleDependency.Version.VERSION_UPDATER)
id(config.GradleDependency.DEPENDENCY_GRAPH).version(config.GradleDependency.Version.DEPENDENCY_GRAPH)
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
// required to find the project's artifacts
maven { url = uri("https://dl.bintray.com/pokk/maven") }
maven { url = uri("https://dl.bintray.com/kotlin/kotlin-eap") }
maven { url = uri("https://dl.bintray.com/kodein-framework/Kodein-DI") }
}
tasks {
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
suppressWarnings = false
freeCompilerArgs = listOf(
"-Xuse-experimental=kotlin.Experimental",
"-Xuse-experimental=kotlin.ExperimentalStdlibApi",
"-Xuse-experimental=kotlin.ExperimentalContracts",
"-Xuse-experimental=org.mylibrary.ExperimentalMarker",
"-Xallow-result-return-type",
"-Xjvm-default=all"
)
}
}
}
}
val modules = config.CommonModuleDependency.getLibraryModuleSimpleName()
val features = config.CommonModuleDependency.getFeatureModuleSimpleName()
subprojects {
beforeEvaluate {
//region Apply plugin
apply {
when (name) {
"ext" -> {
plugin("java-library")
plugin("kotlin")
}
in modules -> {
plugin("com.android.library")
plugin("kotlin-android")
}
in features -> {
plugin("com.android.dynamic-feature")
plugin("kotlin-android")
plugin("kotlin-parcelize")
plugin("kotlin-kapt")
plugin("androidx.navigation.safeargs.kotlin")
}
}
if (name == "core") {
plugin("org.jetbrains.kotlin.kapt")
}
plugin(config.GradleDependency.DETEKT)
plugin("project-report") // for generating dependency graph
// plugin("org.jlleitschuh.gradle.ktlint")
}
//endregion
}
afterEvaluate {
//region Common Setting
if (name !in listOf("ext", "feature")) {
// BaseExtension is common parent for application, library and test modules
extensions.configure<BaseExtension> {
compileSdkVersion(config.AndroidConfiguration.COMPILE_SDK)
defaultConfig {
minSdkVersion(config.AndroidConfiguration.MIN_SDK)
targetSdkVersion(config.AndroidConfiguration.TARGET_SDK)
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner = config.AndroidConfiguration.TEST_INSTRUMENTATION_RUNNER
consumerProguardFiles(file("consumer-rules.pro"))
if ([email protected] in features) {
applyRoomSetting()
}
}
buildTypes {
getByName("release") {
if ([email protected] !in features) {
isMinifyEnabled = true
}
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
file("proguard-rules.pro")
)
}
getByName("debug") {
splits.abi.isEnable = false
splits.density.isEnable = false
aaptOptions.cruncherEnabled = false
isTestCoverageEnabled = true
// Only use this flag on builds you don't proguard or upload to beta-by-crashlytics.
ext.set("alwaysUpdateBuildId", false)
isCrunchPngs = false // Enabled by default for RELEASE build type
}
}
dexOptions {
jumboMode = true
preDexLibraries = true
threadCount = 8
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
lintOptions {
isAbortOnError = false
isIgnoreWarnings = true
isQuiet = true
}
testOptions {
unitTests {
isReturnDefaultValues = true
isIncludeAndroidResources = true
}
}
if ([email protected] !in modules) {
buildFeatures.viewBinding = true
}
}
}
if (name in features + listOf("app", "core")) {
extensions.configure<KaptExtension> {
useBuildCache = true
correctErrorTypes = true
mapDiagnosticLocations = true
}
}
//endregion
}
}
fun DefaultConfig.applyRoomSetting() {
javaCompileOptions {
annotationProcessorOptions {
arguments["room.schemaLocation"] = "$projectDir/schemas"
arguments["room.incremental"] = "true"
arguments["room.expandProjection"] = "true"
}
}
}
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
dependencyGraphGenerator {
generators = listOf(com.vanniktech.dependency.graph.generator.DependencyGraphGeneratorExtension.Generator.ALL)
}