-
Notifications
You must be signed in to change notification settings - Fork 321
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
183 lines (168 loc) · 7.77 KB
/
build.gradle.kts
File metadata and controls
183 lines (168 loc) · 7.77 KB
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 org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.TestExecutable
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
buildscript {
repositories {
// maven { setUrl("https://maven.aliyun.com/repository/public") } // central、jcenter
// maven { setUrl("https://maven.aliyun.com/repository/google") } // google
// maven { setUrl("https://repo.huaweicloud.com/repository/maven/") } // central、google、jcenter
// maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
gradlePluginPortal()
mavenCentral()
google()
}
dependencies {
classpath(libs.gradlePlugin.android)
classpath(libs.gradlePlugin.androidxNavigationSafeArgs)
classpath(libs.gradlePlugin.buildkonfig)
classpath(libs.gradlePlugin.jetbrainsCompose)
classpath(libs.gradlePlugin.kotlin)
classpath(libs.gradlePlugin.kotlinComposeCompiler)
classpath(libs.gradlePlugin.kotlinSerialization)
classpath(libs.gradlePlugin.kotlinxAtomicfu)
classpath(libs.gradlePlugin.kotlinxCover)
classpath(libs.gradlePlugin.mavenPublish)
}
}
plugins {
alias(libs.plugins.dokka)
}
tasks.register("cleanRootBuild", Delete::class) {
delete(rootProject.project.layout.buildDirectory.get().asFile.absolutePath)
}
// Aggregate dokka documentation for all submodules
dependencies {
for (module in publicModules) {
dokka(project(":$module"))
}
}
allprojects {
repositories {
// maven { setUrl("https://maven.aliyun.com/repository/public") } // central、jcenter
// maven { setUrl("https://maven.aliyun.com/repository/google") } // google
// maven { setUrl("https://repo.huaweicloud.com/repository/maven/") } // central、google、jcenter
mavenCentral()
google()
maven { setUrl("https://www.jitpack.io") }
// maven { setUrl("https://s01.oss.sonatype.org/content/repositories/snapshots") }
// mavenLocal()
}
// Minimum compatible Java version
afterEvaluate {
// Must be included in afterEvaluate to find the plugin
// Compose Multiplatform 1.8.0 must use JVM target 11+, and Android View also requires 1.8+
val (version, target) = if (plugins.findPlugin("org.jetbrains.kotlin.plugin.compose") != null) {
JavaVersion.VERSION_11 to JvmTarget.JVM_11
} else {
JavaVersion.VERSION_1_8 to JvmTarget.JVM_1_8
}
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = version.toString()
targetCompatibility = version.toString()
options.compilerArgs = options.compilerArgs + "-Xlint:-options"
}
tasks.withType<KotlinJvmCompile>().configureEach {
compilerOptions.jvmTarget = target
}
}
// 'expect'/'actual' classes (including interfaces, objects, annotations, enums, and 'actual' typealiases) are in Beta. Consider using the '-Xexpect-actual-classes' flag to suppress this warning.
// Also see: https://youtrack.jetbrains.com/issue/KT-61573
plugins.withId("org.jetbrains.kotlin.multiplatform") {
extensions.configure<KotlinMultiplatformExtension> {
targets.configureEach {
compilations.configureEach {
compileTaskProvider.configure {
compilerOptions {
freeCompilerArgs.addAll(listOf("-Xexpect-actual-classes"))
}
}
}
}
}
}
// Can't dispatch to the main thread in native tests. https://youtrack.jetbrains.com/issue/KT-53129
plugins.withId("org.jetbrains.kotlin.multiplatform") {
extensions.configure<KotlinMultiplatformExtension> {
targets.withType<KotlinNativeTarget> {
if (konanTarget.family.isAppleFamily) {
binaries.withType<TestExecutable> {
freeCompilerArgs += listOf(
"-e",
"com.github.panpf.sketch.test.utils.mainBackground"
)
}
}
}
}
}
// Add compilation configuration for Compose module
plugins.withId("org.jetbrains.kotlin.plugin.compose") {
extensions.configure<ComposeCompilerGradlePluginExtension> {
stabilityConfigurationFiles.add {
rootDir.resolve("sketch-core/compose_compiler_config.conf")
}
}
}
/*
* Run the `./gradlew clean :sketch-compose:assembleRelease -PcomposeCompilerReports=true` command to generate a report,
* which is located in the `project/module/build/compose_compiler` directory.
*
* Interpretation of the report: https://developer.android.com/jetpack/compose/performance/stability/diagnose#kotlin
*/
if (project.findProperty("composeCompilerReports") == "true") {
plugins.withId("org.jetbrains.kotlin.plugin.compose") {
extensions.configure<ComposeCompilerGradlePluginExtension> {
val outputDir = layout.buildDirectory.dir("compose_compiler").get().asFile
metricsDestination = outputDir
reportsDestination = outputDir
}
}
}
// jetbrains-compose bug https://youtrack.jetbrains.com/issue/CMP-5831
configurations.all {
resolutionStrategy.eachDependency {
if (requested.group == "org.jetbrains.kotlinx" && requested.name == "atomicfu") {
useVersion(libs.versions.kotlinx.atomicfu.get())
}
}
}
// Uninstall test APKs after running instrumentation tests.
tasks.configureEach {
if (name == "connectedDebugAndroidTest") {
finalizedBy("uninstallDebugAndroidTest")
}
}
// Configure publish plugin for all publishable library modules
if (
// && hasProperty("mavenCentralUsername") // configured in the ~/.gradle/gradle.properties file
// && hasProperty("mavenCentralPassword") // configured in the ~/.gradle/gradle.properties file
hasProperty("versionName") // configured in the rootProject/gradle.properties file
&& hasProperty("GROUP") // configured in the rootProject/gradle.properties file
&& hasProperty("POM_ARTIFACT_ID") // configured in the project/gradle.properties file
) {
apply { plugin("com.vanniktech.maven.publish") }
configure<com.vanniktech.maven.publish.MavenPublishBaseExtension> {
version = property("versionName").toString()
if (hasProperty("signing.keyId") // configured in the ~/.gradle/gradle.properties file
&& hasProperty("signing.password") // configured in the ~/.gradle/gradle.properties file
&& hasProperty("signing.secretKeyRingFile") // configured in the ~/.gradle/gradle.properties file
) {
signAllPublications()
} else if (
System.getenv("ORG_GRADLE_PROJECT_signingInMemoryKey").orEmpty()
.isNotEmpty() // configured in the github workflow env
&& System.getenv("ORG_GRADLE_PROJECT_signingInMemoryKeyPassword").orEmpty()
.isNotEmpty() // configured in the github workflow env
) {
signAllPublications()
}
}
}
// Configure Dokka plugin for all publishable library modules
if (hasProperty("POM_ARTIFACT_ID")) { // configured in the module/gradle.properties file
apply { plugin("org.jetbrains.dokka") }
}
}