@@ -31,6 +31,56 @@ subprojects {
3131 }
3232}
3333
34+ /*
35+ * Release pre-flight: the split ships core, core-android, device and server in lockstep
36+ * (one version, one run), so the set of published artifacts and their
37+ * coordinates are asserted here and the release workflow fails before anything is
38+ * uploaded if they drift. If you add or remove a published module, update this list
39+ * deliberately.
40+ */
41+ val expectedReleaseArtifacts = sortedSetOf(
42+ " io.ably.pubsub:core:jar" ,
43+ " io.ably.pubsub:core-android:aar" ,
44+ " io.ably.pubsub:device:jar" ,
45+ " io.ably.pubsub:server:jar" ,
46+ " io.ably.pubsub:liveobjects:jar" ,
47+ " io.ably.pubsub:pubsub-adapter:jar" ,
48+ " io.ably.pubsub:network-client-core:jar" ,
49+ " io.ably.pubsub:network-client-default:jar" ,
50+ " io.ably.pubsub:network-client-okhttp:jar" ,
51+ )
52+
53+ tasks.register(" verifyReleaseArtifacts" ) {
54+ description = " Asserts the published artifact set, group and lockstep version before a release."
55+ doLast {
56+ val rootVersion = project.property(" VERSION_NAME" ) as String
57+ val actual = sortedSetOf<String >()
58+ subprojects.filter { it.pluginManager.hasPlugin(" com.vanniktech.maven.publish" ) }.forEach { p ->
59+ val artifactId = p.findProperty(" POM_ARTIFACT_ID" )
60+ ? : error(" ${p.path} applies maven-publish but has no POM_ARTIFACT_ID" )
61+ val packaging = p.findProperty(" POM_PACKAGING" ) ? : " jar"
62+ // The version each module publishes at comes from its effective VERSION_NAME
63+ // (a module-local gradle.properties can override the root's — exactly the
64+ // lockstep drift this guards against).
65+ val moduleVersion = p.findProperty(" VERSION_NAME" )
66+ if (moduleVersion != rootVersion) {
67+ error(" Lockstep violation: ${p.path} has VERSION_NAME $moduleVersion , expected $rootVersion " )
68+ }
69+ val group = p.findProperty(" GROUP" )
70+ actual.add(" $group :$artifactId :$packaging " )
71+ }
72+ if (actual != expectedReleaseArtifacts) {
73+ error(
74+ " Published artifact set does not match the expected release set.\n " +
75+ " expected: $expectedReleaseArtifacts \n " +
76+ " actual: $actual \n " +
77+ " If this change is deliberate, update expectedReleaseArtifacts in build.gradle.kts."
78+ )
79+ }
80+ logger.lifecycle(" Release pre-flight OK: ${actual.size} artifacts at $rootVersion : $actual " )
81+ }
82+ }
83+
3484configure(subprojects) {
3585 pluginManager.withPlugin(" com.vanniktech.maven.publish" ) {
3686 extensions.configure<MavenPublishBaseExtension > {
0 commit comments