forked from fornewid/naver-map-compose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
120 lines (108 loc) · 3.78 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
import com.android.build.api.variant.AndroidComponentsExtension
import com.android.build.api.variant.HasUnitTestBuilder
import com.diffplug.gradle.spotless.SpotlessExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
alias(libs.plugins.spotless) apply false
alias(libs.plugins.gradle.publish.maven) apply false
}
buildscript {
repositories {
google {
content {
includeGroupByRegex(".*google.*")
includeGroupByRegex(".*android.*")
}
}
mavenCentral()
}
dependencies {
classpath(libs.kotlin.gradle.core)
classpath(libs.gradle.android)
}
}
subprojects {
group = project.property("GROUP") as String
version = project.property("VERSION_NAME") as String
repositories {
google {
content {
includeGroupByRegex(".*google.*")
includeGroupByRegex(".*android.*")
}
}
mavenCentral()
maven("https://repository.map.naver.com/archive/maven") {
content {
includeGroup("com.naver.maps")
}
}
}
apply {
plugin(rootProject.libs.plugins.spotless.get().pluginId)
}
// https://github.com/chrisbanes/tivi/blob/0865be537f2859d267efb59dac7d6358eb47effc/gradle/build-logic/convention/src/main/kotlin/app/tivi/gradle/Android.kt#L28-L34
extensions.findByType<AndroidComponentsExtension<*, *, *>>()?.run {
beforeVariants(selector().withBuildType("release")) { variantBuilder ->
(variantBuilder as? HasUnitTestBuilder)?.apply {
enableUnitTest = false
}
}
}
extensions.configure<SpotlessExtension> {
kotlin {
target("**/*.kt")
targetExclude("**/build/**/*.kt")
ktlint(rootProject.libs.versions.ktlint.get()).editorConfigOverride(
mapOf(
"indent_size" to "2",
"ktlint_standard_filename" to "disabled",
"ktlint_standard_package-name" to "disabled",
"ktlint_standard_property-naming" to "disabled",
"ktlint_standard_function-naming" to "disabled",
"ktlint_standard_import-ordering" to "disabled",
"ktlint_standard_max-line-length" to "disabled",
"ktlint_standard_annotation" to "disabled",
"ktlint_standard_multiline-if-else" to "disabled",
"ktlint_standard_value-argument-comment" to "disabled",
"ktlint_standard_value-parameter-comment" to "disabled",
"ktlint_standard_comment-wrapping" to "disabled",
)
)
licenseHeaderFile(rootProject.file("spotless/copyright.kt"))
}
format("kts") {
target("**/*.kts")
targetExclude("**/build/**/*.kts")
// Look for the first line that doesn't have a block comment (assumed to be the license)
licenseHeaderFile(rootProject.file("spotless/copyright.kts"), "(^(?![\\/ ]\\*).*$)")
}
format("xml") {
target("**/*.xml")
targetExclude("**/build/**/*.xml")
// Look for the first XML tag that isn't a comment (<!--) or the xml declaration (<?xml)
licenseHeaderFile(rootProject.file("spotless/copyright.xml"), "(<[^!?])")
}
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "17"
freeCompilerArgs = freeCompilerArgs + listOf(
"-opt-in=kotlin.OptIn",
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=kotlin.contracts.ExperimentalContracts",
)
// https://github.com/ZacSweers/redacted-compiler-plugin/blob/c866a8ae7b2ab039fee9709c990a5478ac0dc0c7/redacted-compiler-plugin-gradle/build.gradle.kts#L91-L94
if (project.hasProperty("POM_ARTIFACT_ID")) {
moduleName = project.property("POM_ARTIFACT_ID") as String
}
}
}
tasks.withType<Test>().configureEach {
useJUnitPlatform()
outputs.upToDateWhen { false }
}
}
tasks.register<Delete>("cleanAll") {
allprojects.map { project -> project.layout.buildDirectory }.forEach(::delete)
}