-
-
Notifications
You must be signed in to change notification settings - Fork 77
/
build.gradle.kts
125 lines (109 loc) · 3.45 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
/*
* Copyright (C) 2020. Maximilian Keppeler (https://www.maxkeppeler.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import com.android.build.gradle.LibraryExtension
plugins {
id(Plugins.APPLICATION.id) version (Plugins.APPLICATION.version) apply false
id(Plugins.LIBRARY.id) version (Plugins.APPLICATION.version) apply false
id(Plugins.KOTLIN.id) version (Plugins.KOTLIN.version) apply false
id(Plugins.SPOTLESS.id) version (Plugins.SPOTLESS.version)
id(Plugins.DOKKA.id) version (Plugins.DOKKA.version)
}
buildscript {
repositories {
google()
mavenCentral()
maven("https://plugins.gradle.org/m2/")
}
dependencies {
classpath(Dependencies.Kotlin.GRADLE_PLUGIN)
classpath(Dependencies.Gradle.BUILD)
classpath(Dependencies.MAVEN_PUBLISH)
classpath(Dependencies.DOKKA)
}
}
allprojects {
repositories {
google()
mavenCentral()
maven("https://jitpack.io")
}
}
tasks.dokkaHtmlMultiModule.configure {
outputDirectory.set(projectDir.resolve("docs/api"))
}
subprojects {
plugins.apply(Plugins.SPOTLESS.id)
project.plugins.applyBaseConfig(project)
spotless {
kotlin {
target("**/*.kt")
licenseHeaderFile(rootProject.file("copyright.kt"))
}
kotlinGradle {
target("*.gradle.kts", "gradle/*.gradle.kts", "buildSrc/*.gradle.kts")
licenseHeaderFile(
rootProject.file("copyright.kt"),
"import|tasks|apply|plugins|rootProject"
)
}
}
}
/**
* Apply base configurations to the subjects that include specific custom plugins.
*/
fun PluginContainer.applyBaseConfig(project: Project) {
whenPluginAdded {
when (this) {
is LibraryModulePlugin -> {
project.extensions
.getByType<LibraryExtension>()
.apply {
baseLibraryConfig()
}
}
}
}
}
/**
* Apply base library configurations to the subprojects that include the plugin [LibraryModulePlugin].
*/
fun com.android.build.gradle.BaseExtension.baseLibraryConfig() {
compileSdkVersion(App.COMPILE_SDK)
defaultConfig {
minSdk = App.MIN_SDK
targetSdk = App.TARGET_SDK
testInstrumentationRunner = App.TEST_INSTRUMENTATION_RUNNER
}
compileOptions.apply {
sourceCompatibility(JavaVersion.VERSION_1_8)
targetCompatibility(JavaVersion.VERSION_1_8)
}
buildFeatures.viewBinding = true
packagingOptions.resources.excludes += listOf(
"META-INF/DEPENDENCIES.txt",
"META-INF/LICENSE",
"META-INF/LICENSE.txt",
"META-INF/NOTICE",
"META-INF/NOTICE.txt",
"META-INF/AL2.0",
"META-INF/LGPL2.1"
)
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
}
}
}