-
Notifications
You must be signed in to change notification settings - Fork 4k
/
build.gradle.kts
183 lines (162 loc) · 5.83 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
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.SonatypeHost
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
import java.net.URL
import kotlinx.validation.ApiValidationExtension
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
buildscript {
repositories {
google()
gradlePluginPortal()
mavenCentral()
}
dependencies {
classpath(libs.gradlePlugin.android)
classpath(libs.gradlePlugin.kotlin)
classpath(libs.gradlePlugin.dokka)
classpath(libs.gradlePlugin.mavenPublish)
classpath(libs.gradlePlugin.detekt)
classpath(libs.gradlePlugin.binaryCompatibility)
classpath(libs.gradlePlugin.keeper)
classpath(libs.gradlePlugin.sqldelight)
classpath("com.google.dagger:hilt-android-gradle-plugin:2.43.2")
}
}
// We use JetBrain's Kotlin Binary Compatibility Validator to track changes to our public binary
// APIs.
// When making a change that results in a public ABI change, the apiCheck task will fail. When this
// happens, run ./gradlew apiDump to generate updated *.api files, and add those to your commit.
// See https://github.com/Kotlin/binary-compatibility-validator
apply(plugin = "binary-compatibility-validator")
extensions.configure<ApiValidationExtension> {
// Ignore projects that are not uploaded to Maven Central
ignoredProjects += listOf("leakcanary-app", "leakcanary-android-sample", "shark-test", "shark-hprof-test", "shark-cli")
}
// This plugin needs to be applied to the root projects for the dokkaGfmCollector task we use to
// generate the documentation site.
apply(plugin = "org.jetbrains.dokka")
repositories {
// Needed for the Dokka plugin.
gradlePluginPortal()
}
// Config shared for all subprojects
subprojects {
repositories {
google()
mavenCentral()
// maven {
// url 'https://oss.sonatype.org/content/repositories/snapshots/'
// }
// mavenLocal()
jcenter()
}
apply(plugin = "io.gitlab.arturbosch.detekt")
tasks.withType<JavaCompile> {
options.compilerArgs.addAll(
listOf(
"-Xlint:all",
"-Xlint:-serial",
"-Xlint:-deprecation",
// espresso-core classes say they're compiled with 51.0 but contain 52.0 attributes.
// warning: [classfile] MethodParameters attribute introduced in version 52.0 class files is ignored in version 51.0 class files
// "-Werror"
)
)
}
tasks.withType<Test> {
testLogging {
exceptionFormat = TestExceptionFormat.FULL
showCauses = true
showExceptions = true
showStackTraces = true
}
}
extensions.configure<DetektExtension> {
config = rootProject.files("config/detekt-config.yml")
parallel = true
reports {
xml.enabled = false
}
}
pluginManager.withPlugin("java") {
tasks.named("check") { dependsOn("detekt") }
tasks.named("assemble") { dependsOn(rootProject.tasks.named("installGitHooks")) }
tasks.named("clean") { dependsOn(rootProject.tasks.named("installGitHooks")) }
}
}
// Config shared for subprojects except leakcanary-deobfuscation-gradle-plugin
configure(subprojects.filter {
it.name !in listOf("leakcanary-deobfuscation-gradle-plugin")
}) {
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
// Config shared for subprojects except apps
configure(subprojects.filter {
it.name !in listOf("leakcanary-app", "leakcanary-android-sample")
}) {
// Note: to skip Dokka on some projects we could add it individually to projects we actually
// want.
apply(plugin = "org.jetbrains.dokka")
group = property("GROUP").toString()
version = property("VERSION_NAME").toString()
tasks.withType<DokkaTask> {
dokkaSourceSets.configureEach {
reportUndocumented.set(false)
displayName.set(null as String?)
platform.set(org.jetbrains.dokka.Platform.jvm)
perPackageOption {
// will match all .internal packages and sub-packages
matchingRegex.set("(.*\\.internal.*)")
suppress.set(true)
}
perPackageOption {
// BuildConfig files
matchingRegex.set("com.squareup.leakcanary\\..*")
suppress.set(true)
}
skipDeprecated.set(true)
externalDocumentationLink {
url.set(URL("https://square.github.io/okio/2.x/okio/"))
}
externalDocumentationLink {
url.set(URL("https://square.github.io/moshi/1.x/moshi/"))
}
}
}
pluginManager.withPlugin("com.vanniktech.maven.publish") {
extensions.configure<MavenPublishBaseExtension> {
publishToMavenCentral(SonatypeHost.S01)
signAllPublications()
}
}
}
//Copies git hooks from /hooks folder into .git; currently used to run Detekt during push
//Git hook installation
tasks.register<Copy>("installGitHooks") {
from(File(rootProject.rootDir, "config/hooks"))
into({ File(rootProject.rootDir, ".git/hooks") })
fileMode = "0777".toInt(8) // Make files executable
}
tasks.register<Copy>("siteDokka") {
description = "Generate dokka Github-flavored Markdown for the documentation site."
group = "documentation"
dependsOn(":dokkaGfmCollector")
// Copy the files instead of configuring a different output directory on the dokka task itself
// since the default output directories disambiguate between different types of outputs, and our
// custom directory doesn't.
from(layout.buildDirectory.dir("dokka/gfmCollector/leakcanary-repo"))
// For whatever reason Dokka doesn't want to ignore the packages we told it to ignore.
// Fine, we'll just ignore it here.
exclude("**/com.example.leakcanary/**")
into(rootProject.file("docs/api"))
filter { line ->
// Dokka adds [main]\ and [main]<br> everywhere, this just removes it.
line.replace("\\[main\\]\\\\", "").replace("\\[main\\]<br>", "")
}
}