Repository navigation
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
118 lines (110 loc) · 5.22 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
118 lines (110 loc) · 5.22 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
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.maven.publish) apply false
alias(libs.plugins.lombok) apply false
alias(libs.plugins.test.retry) apply false
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.kotlin.compose) apply false
}
subprojects {
repositories {
google()
mavenCentral()
}
tasks.withType<Javadoc> {
// To prevent javadoc warnings with Java 8
options {
this as StandardJavadocDocletOptions
addBooleanOption("Xdoclint:none", true)
addBooleanOption("quiet", true)
addStringOption("Xmaxwarns", "1")
}
}
}
/*
* Release pre-flight: the split ships core, core-android, device and server in lockstep
* (one version, one run), so the set of published artifacts and their
* coordinates are asserted here and the release workflow fails before anything is
* uploaded if they drift. If you add or remove a published module, update this list
* deliberately.
*/
val expectedReleaseArtifacts = sortedSetOf(
"io.ably.pubsub:core:jar",
"io.ably.pubsub:core-android:aar",
// `device` is Kotlin Multiplatform: `device` is the root (metadata) publication and the
// real artifacts are the `device-jvm` and `device-android` target publications below;
// the root entry is modelled as `jar` only because it has no packaging of its own.
"io.ably.pubsub:device:jar",
"io.ably.pubsub:device-jvm:jar",
"io.ably.pubsub:device-android:aar",
"io.ably.pubsub:server:jar",
"io.ably.pubsub:liveobjects:jar",
"io.ably.pubsub:pubsub-adapter:jar",
"io.ably.pubsub:network-client-core:jar",
"io.ably.pubsub:network-client-default:jar",
"io.ably.pubsub:network-client-okhttp:jar",
)
tasks.register("verifyReleaseArtifacts") {
description = "Asserts the published artifact set, group and lockstep version before a release."
doLast {
val rootVersion = project.property("VERSION_NAME") as String
val actual = sortedSetOf<String>()
subprojects.filter { it.pluginManager.hasPlugin("com.vanniktech.maven.publish") }.forEach { p ->
val artifactId = p.findProperty("POM_ARTIFACT_ID")
?: error("${p.path} applies maven-publish but has no POM_ARTIFACT_ID")
val packaging = p.findProperty("POM_PACKAGING") ?: "jar"
// The version each module publishes at comes from its effective VERSION_NAME
// (a module-local gradle.properties can override the root's — exactly the
// lockstep drift this guards against).
val moduleVersion = p.findProperty("VERSION_NAME")
if (moduleVersion != rootVersion) {
error("Lockstep violation: ${p.path} has VERSION_NAME $moduleVersion, expected $rootVersion")
}
val group = p.findProperty("GROUP")
actual.add("$group:$artifactId:$packaging")
// A Kotlin Multiplatform module (`device`) does not publish as a single jar: its
// POM_ARTIFACT_ID names only the root metadata publication (the one a plain
// dependency resolves through Gradle module metadata), and the real artifacts are
// the per-target publications (`device-jvm`, `device-android`). Record those from the
// module's actual publications so a dropped target fails the check.
if (p.pluginManager.hasPlugin("org.jetbrains.kotlin.multiplatform")) {
p.extensions.getByType<PublishingExtension>().publications
.withType<MavenPublication>()
.filter { it.artifactId != artifactId }
.forEach { pub ->
val ext = if (pub.artifactId.endsWith("-android")) "aar" else "jar"
actual.add("$group:${pub.artifactId}:$ext")
}
}
}
if (actual != expectedReleaseArtifacts) {
error(
"Published artifact set does not match the expected release set.\n" +
" expected: $expectedReleaseArtifacts\n" +
" actual: $actual\n" +
"If this change is deliberate, update expectedReleaseArtifacts in build.gradle.kts."
)
}
logger.lifecycle("Release pre-flight OK: ${actual.size} artifacts at $rootVersion: $actual")
}
}
configure(subprojects) {
pluginManager.withPlugin("com.vanniktech.maven.publish") {
extensions.configure<MavenPublishBaseExtension> {
// Check if we're running a local publish task
val isLocalPublish = gradle.startParameter.taskNames.any {
it.contains("publishToMavenLocal") || it.contains("ToMavenLocal")
}
if (!isLocalPublish) {
signAllPublications()
}
}
}
}