Skip to content

Commit ac85f0f

Browse files
Nguyễn Tuấn Việtclaude
andcommitted
Downgrade Kotlin to 2.1.0 and add Maven Central checksums support
- Downgrade Kotlin from 2.2.20 to 2.1.0 to work around K2 compiler crash with iOS interop when using .apply{} on platform classes - Add generateChecksums task to generate MD5/SHA1 checksums for Maven Central - Add publishAndroidWithChecksums task for Android-only publishing - Import necessary classes for checksum generation Resolves iOS compilation issues with: - UNMutableNotificationContent.apply{} - BGProcessingTaskRequest.apply{} K2 compiler bug reported to YouTrack (Kotlin 2.2.20) All artifacts now ready for Maven Central publishing with full checksums 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 0ef52aa commit ac85f0f

File tree

2 files changed

+104
-1
lines changed

2 files changed

+104
-1
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ androidx-lifecycle = "2.9.4"
1111
androidx-testExt = "1.3.0"
1212
composeMultiplatform = "1.9.0"
1313
junit = "4.13.2"
14-
kotlin = "2.2.20"
14+
kotlin = "2.1.0"
1515

1616
koin = "4.1.1"
1717
kotlinx-datetime = "0.7.1"

kmptaskmanager/build.gradle.kts

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
22
import java.util.Base64
3+
import java.security.MessageDigest
4+
import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven
5+
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
36

47
plugins {
58
alias(libs.plugins.kotlinMultiplatform)
@@ -133,6 +136,106 @@ publishing {
133136
}
134137
}
135138

139+
tasks.withType<GenerateModuleMetadata>().configureEach {
140+
enabled = true
141+
}
142+
143+
// Task to generate MD5 and SHA1 checksums for Maven Central
144+
tasks.register("generateChecksums") {
145+
group = "publishing"
146+
description = "Generate MD5 and SHA1 checksums for Maven Central artifacts"
147+
148+
dependsOn("publishAllPublicationsToMavenCentralLocalRepository")
149+
150+
doLast {
151+
val stagingDir = project.layout.buildDirectory.dir("maven-central-staging").get().asFile
152+
if (!stagingDir.exists()) {
153+
logger.warn("Staging directory does not exist: $stagingDir")
154+
return@doLast
155+
}
156+
157+
var checksumCount = 0
158+
stagingDir.walk().forEach { file ->
159+
if (file.isFile && !file.name.endsWith(".md5") && !file.name.endsWith(".sha1")
160+
&& !file.name.endsWith(".sha256") && !file.name.endsWith(".sha512")
161+
&& !file.name.endsWith(".asc")) {
162+
163+
// Generate MD5
164+
val md5File = File(file.parentFile, "${file.name}.md5")
165+
if (!md5File.exists()) {
166+
val md5 = MessageDigest.getInstance("MD5")
167+
.digest(file.readBytes())
168+
.joinToString("") { byte -> "%02x".format(byte) }
169+
md5File.writeText(md5)
170+
checksumCount++
171+
logger.lifecycle("Generated MD5: ${md5File.relativeTo(stagingDir)}")
172+
}
173+
174+
// Generate SHA1
175+
val sha1File = File(file.parentFile, "${file.name}.sha1")
176+
if (!sha1File.exists()) {
177+
val sha1 = MessageDigest.getInstance("SHA-1")
178+
.digest(file.readBytes())
179+
.joinToString("") { byte -> "%02x".format(byte) }
180+
sha1File.writeText(sha1)
181+
checksumCount++
182+
logger.lifecycle("Generated SHA1: ${sha1File.relativeTo(stagingDir)}")
183+
}
184+
}
185+
}
186+
187+
logger.lifecycle("Generated $checksumCount checksum files in $stagingDir")
188+
}
189+
}
190+
191+
// Task to publish only Android artifacts (workaround for iOS compilation issues)
192+
tasks.register("publishAndroidWithChecksums") {
193+
group = "publishing"
194+
description = "Publish only Android artifacts with checksums to Maven Central"
195+
196+
dependsOn("publishAndroidReleasePublicationToMavenCentralLocalRepository")
197+
198+
doLast {
199+
val stagingDir = project.layout.buildDirectory.dir("maven-central-staging").get().asFile
200+
if (!stagingDir.exists()) {
201+
logger.warn("Staging directory does not exist: $stagingDir")
202+
return@doLast
203+
}
204+
205+
var checksumCount = 0
206+
stagingDir.walk().forEach { file ->
207+
if (file.isFile && !file.name.endsWith(".md5") && !file.name.endsWith(".sha1")
208+
&& !file.name.endsWith(".sha256") && !file.name.endsWith(".sha512")
209+
&& !file.name.endsWith(".asc")) {
210+
211+
// Generate MD5
212+
val md5File = File(file.parentFile, "${file.name}.md5")
213+
if (!md5File.exists()) {
214+
val md5 = MessageDigest.getInstance("MD5")
215+
.digest(file.readBytes())
216+
.joinToString("") { byte -> "%02x".format(byte) }
217+
md5File.writeText(md5)
218+
checksumCount++
219+
logger.lifecycle("Generated MD5: ${md5File.relativeTo(stagingDir)}")
220+
}
221+
222+
// Generate SHA1
223+
val sha1File = File(file.parentFile, "${file.name}.sha1")
224+
if (!sha1File.exists()) {
225+
val sha1 = MessageDigest.getInstance("SHA-1")
226+
.digest(file.readBytes())
227+
.joinToString("") { byte -> "%02x".format(byte) }
228+
sha1File.writeText(sha1)
229+
checksumCount++
230+
logger.lifecycle("Generated SHA1: ${sha1File.relativeTo(stagingDir)}")
231+
}
232+
}
233+
}
234+
235+
logger.lifecycle("Generated $checksumCount checksum files for Android artifacts in $stagingDir")
236+
}
237+
}
238+
136239
signing {
137240
val signingKeyBase64 = project.findProperty("signing.key") as String?
138241
val signingPassword = project.findProperty("signing.password") as String? ?: ""

0 commit comments

Comments
 (0)