-
Notifications
You must be signed in to change notification settings - Fork 15
/
build.gradle.kts
102 lines (87 loc) · 3.15 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
import com.vanniktech.maven.publish.AndroidSingleVariantLibrary
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.SonatypeHost
import kotlinx.validation.ApiValidationExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jlleitschuh.gradle.ktlint.KtlintExtension
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType
println("Building with Kotlin compiler version ${Versions.KotlinCompiler}")
buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
google()
// For binary compatibility validator.
maven { url = uri("https://kotlin.bintray.com/kotlinx") }
}
dependencies {
classpath(Dependencies.Build.Android)
classpath(Dependencies.Build.MavenPublish)
classpath(Dependencies.Build.Kotlin)
classpath(Dependencies.Build.Ktlint)
classpath(Dependencies.Build.BinaryCompatibility)
}
}
// 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 all sample projects, since they're not part of our API.
// Only leaf project name is valid configuration, and every project must be individually ignored.
// See https://github.com/Kotlin/binary-compatibility-validator/issues/3
ignoredProjects = mutableSetOf(
"sample"
)
}
// See https://stackoverflow.com/questions/25324880/detect-ide-environment-with-gradle
val isRunningFromIde get() = project.properties["android.injected.invoked.from.ide"] == "true"
subprojects {
repositories {
google()
mavenCentral()
}
apply(plugin = "org.jlleitschuh.gradle.ktlint")
plugins.withId("com.vanniktech.maven.publish.base") {
configure<MavenPublishBaseExtension> {
publishToMavenCentral(SonatypeHost.S01)
signAllPublications()
pomFromGradleProperties()
configure(
AndroidSingleVariantLibrary(variant = "release", sourcesJar = true, publishJavadocJar = true),
)
}
}
tasks.withType<KotlinCompile> {
kotlinOptions {
// Allow warnings when running from IDE, makes it easier to experiment.
if (!isRunningFromIde) {
allWarningsAsErrors = true
}
jvmTarget = "1.8"
}
}
// Configuration documentation: https://github.com/JLLeitschuh/ktlint-gradle#configuration
configure<KtlintExtension> {
// Enable Kotlin 1.4 support.
version.set("0.38.1")
// Prints the name of failed rules.
verbose.set(true)
reporters {
// Default "plain" reporter is actually harder to read.
reporter(ReporterType.JSON)
}
disabledRules.set(
setOf(
// IntelliJ refuses to sort imports correctly.
// This is a known issue: https://github.com/pinterest/ktlint/issues/527
"import-ordering",
"indent",
"parameter-list-wrapping",
"final-newline"
)
)
}
}