forked from JetBrains/compose-multiplatform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
241 lines (205 loc) · 9.31 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
import org.gradle.api.*
import org.jetbrains.compose.internal.publishing.*
plugins {
signing
}
fun Task.dependsOnComposeTask(name: String) {
dependsOn(project.composeBuild?.task(name) ?: return)
}
open class ComposePublishingTask : AbstractComposePublishingTask() {
override fun dependsOnComposeTask(task: String) {
dependsOn(project.composeBuild?.task(task) ?: return)
}
}
val composeProperties = ComposeProperties(project)
val mainComponents =
listOf(
ComposeComponent(":compose:animation:animation"),
ComposeComponent(":compose:animation:animation-core"),
ComposeComponent(":compose:animation:animation-graphics"),
ComposeComponent(":compose:foundation:foundation"),
ComposeComponent(":compose:foundation:foundation-layout"),
ComposeComponent(":compose:material:material"),
ComposeComponent(":compose:material3:material3"),
ComposeComponent(":compose:material:material-icons-core"),
ComposeComponent(":compose:material:material-ripple"),
ComposeComponent(":compose:runtime:runtime"),
ComposeComponent(":compose:runtime:runtime-saveable"),
ComposeComponent(":compose:ui:ui"),
ComposeComponent(":compose:ui:ui-geometry"),
ComposeComponent(":compose:ui:ui-graphics"),
ComposeComponent(":compose:ui:ui-test", supportedPlatforms = ComposePlatforms.JVM_BASED),
ComposeComponent(":compose:ui:ui-test-junit4", supportedPlatforms = ComposePlatforms.JVM_BASED),
ComposeComponent(":compose:ui:ui-text"),
ComposeComponent(":compose:ui:ui-tooling", supportedPlatforms = ComposePlatforms.JVM_BASED),
ComposeComponent(":compose:ui:ui-tooling-data", supportedPlatforms = ComposePlatforms.JVM_BASED),
ComposeComponent(":compose:ui:ui-tooling-preview", supportedPlatforms = ComposePlatforms.JVM_BASED),
ComposeComponent(":compose:ui:ui-unit"),
ComposeComponent(":compose:ui:ui-util"),
)
val iconsComponents =
listOf(
ComposeComponent(":compose:material:material-icons-extended"),
)
fun ComposePublishingTask.mainPublications() {
publish(
":compose:desktop:desktop",
onlyWithPlatforms = setOf(ComposePlatforms.Desktop),
publications = listOf(
"KotlinMultiplatform",
"Jvm",
"Jvmlinux-x64",
"Jvmlinux-arm64",
"Jvmmacos-x64",
"Jvmmacos-arm64",
"Jvmwindows-x64"
)
)
mainComponents.forEach { publishMultiplatform(it) }
}
fun ComposePublishingTask.iconsPublications() {
iconsComponents.forEach { publishMultiplatform(it) }
}
// To show all projects which use `xxx` task, run:
// ./gradlew -p frameworks/support help --task xxx
tasks.register("publishComposeJb", ComposePublishingTask::class) {
repository = "MavenRepository"
mainPublications()
}
tasks.register("publishComposeJbToMavenLocal", ComposePublishingTask::class) {
repository = "MavenLocal"
mainPublications()
}
// separate task that cannot be built in parallel (because it requires too much RAM).
// should be run with "--max-workers=1"
tasks.register("publishComposeJbExtendedIcons", ComposePublishingTask::class) {
repository = "MavenRepository"
iconsPublications()
}
tasks.register("publishComposeJbExtendedIconsToMavenLocal", ComposePublishingTask::class) {
repository = "MavenLocal"
iconsPublications()
}
tasks.register("testComposeJbDesktop") {
dependsOnComposeTask(":compose:desktop:desktop:jvmTest")
dependsOnComposeTask(":compose:animation:animation:desktopTest")
dependsOnComposeTask(":compose:animation:animation-core:desktopTest")
dependsOnComposeTask(":compose:ui:ui:desktopTest")
dependsOnComposeTask(":compose:ui:ui-graphics:desktopTest")
dependsOnComposeTask(":compose:ui:ui-text:desktopTest")
dependsOnComposeTask(":compose:foundation:foundation:desktopTest")
dependsOnComposeTask(":compose:foundation:foundation-layout:desktopTest")
dependsOnComposeTask(":compose:material:material:desktopTest")
dependsOnComposeTask(":compose:material:material-ripple:desktopTest")
dependsOnComposeTask(":compose:runtime:runtime:desktopTest")
dependsOnComposeTask(":compose:runtime:runtime-saveable:desktopTest")
}
tasks.register("testComposeJbWeb") {
dependsOnComposeTask(":compose:runtime:runtime:jsTest")
dependsOnComposeTask(":compose:runtime:runtime:test")
}
tasks.register("buildNativeDemo") {
dependsOnComposeTask(":compose:native:demo:assemble")
}
tasks.register("testRuntimeNative") {
dependsOnComposeTask(":compose:runtime:runtime:macosX64Test")
}
tasks.register("testComposeModules") { // used in https://github.com/JetBrains/androidx/tree/jb-main/.github/workflows
// TODO: download robolectrict to run ui:ui:test
// dependsOnComposeTask(":compose:ui:ui:test")
dependsOnComposeTask(":compose:ui:ui-graphics:test")
dependsOnComposeTask(":compose:ui:ui-geometry:test")
dependsOnComposeTask(":compose:ui:ui-unit:test")
dependsOnComposeTask(":compose:ui:ui-util:test")
dependsOnComposeTask(":compose:runtime:runtime:test")
dependsOnComposeTask(":compose:runtime:runtime-saveable:test")
dependsOnComposeTask(":compose:material:material:test")
dependsOnComposeTask(":compose:material:material-ripple:test")
dependsOnComposeTask(":compose:foundation:foundation:test")
dependsOnComposeTask(":compose:animation:animation:test")
dependsOnComposeTask(":compose:animation:animation-core:test")
dependsOnComposeTask(":compose:animation:animation-core:test")
// TODO: enable ui:ui-text:test
// dependsOnComposeTask(":compose:ui:ui-text:test")
// compose/out/androidx/compose/ui/ui-text/build/intermediates/tmp/manifest/test/debug/tempFile1ProcessTestManifest10207049054096217572.xml Error:
// android:exported needs to be explicitly specified for <activity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined.
}
tasks.register("run") {
dependsOnComposeTask(":compose:desktop:desktop:desktop-samples:run")
}
for (i in 1..4) {
tasks.register("run$i") {
dependsOnComposeTask(":compose:desktop:desktop:desktop-samples:run$i")
}
}
tasks.register("runWindowApi") {
dependsOnComposeTask(":compose:desktop:desktop:desktop-samples:runWindowApi")
}
tasks.register("runVsync") {
dependsOnComposeTask(":compose:desktop:desktop:desktop-samples:runVsync")
}
tasks.register("runLayout") {
dependsOnComposeTask(":compose:desktop:desktop:desktop-samples:runLayout")
}
tasks.register("runMppJs") {
dependsOnComposeTask(":compose:mpp:demo:jsRun")
}
tasks.register("runMppMacos") {
dependsOnComposeTask(":compose:mpp:demo:runDebugExecutableMacosX64")
}
val mavenCentral = MavenCentralProperties(project)
if (mavenCentral.signArtifacts) {
signing.useInMemoryPgpKeys(
mavenCentral.signArtifactsKey.get(),
mavenCentral.signArtifactsPassword.get()
)
}
val publishingDir = project.layout.buildDirectory.dir("publishing")
val originalArtifactsRoot = publishingDir.map { it.dir("original") }
val preparedArtifactsRoot = publishingDir.map { it.dir("prepared") }
val modulesFile = publishingDir.map { it.file("modules.txt") }
val findComposeModules by tasks.registering(FindModulesInSpaceTask::class) {
requestedGroupId.set("org.jetbrains.compose")
requestedVersion.set(mavenCentral.version)
spaceInstanceUrl.set("https://public.jetbrains.space")
spaceClientId.set(System.getenv("COMPOSE_REPO_USERNAME") ?: "")
spaceClientSecret.set(System.getenv("COMPOSE_REPO_KEY") ?: "")
spaceProjectId.set(System.getenv("COMPOSE_DEV_REPO_PROJECT_ID") ?: "")
spaceRepoId.set(System.getenv("COMPOSE_DEV_REPO_REPO_ID") ?: "")
modulesTxtFile.set(modulesFile)
}
val downloadArtifactsFromComposeDev by tasks.registering(DownloadFromSpaceMavenRepoTask::class) {
dependsOn(findComposeModules)
modulesToDownload.set(project.provider { readComposeModules(modulesFile, originalArtifactsRoot) })
spaceRepoUrl.set("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
val fixModulesBeforePublishing by tasks.registering(FixModulesBeforePublishingTask::class) {
dependsOn(downloadArtifactsFromComposeDev)
inputRepoDir.set(originalArtifactsRoot)
outputRepoDir.set(preparedArtifactsRoot)
}
val reuploadArtifactsToMavenCentral by tasks.registering(UploadToSonatypeTask::class) {
dependsOn(fixModulesBeforePublishing)
version.set(mavenCentral.version)
modulesToUpload.set(project.provider { readComposeModules(modulesFile, preparedArtifactsRoot) })
sonatypeServer.set("https://oss.sonatype.org")
user.set(mavenCentral.user)
password.set(mavenCentral.password)
autoCommitOnSuccess.set(mavenCentral.autoCommitOnSuccess)
stagingProfileName.set("org.jetbrains.compose")
}
fun readComposeModules(
modulesFile: Provider<out FileSystemLocation>,
repoRoot: Provider<out FileSystemLocation>
): List<ModuleToUpload> =
modulesFile.get().asFile.readLines()
.filter { it.isNotBlank() }
.map { line ->
val (group, artifact, version) = line.split(":")
ModuleToUpload(
groupId = group,
artifactId = artifact,
version = version,
localDir = repoRoot.get().asFile.resolve("$group/$artifact/$version")
)
}