Skip to content

Commit c6f1242

Browse files
committed
resource-iterator: change build.gradle.kts for publishing to maven-central
1 parent 5e108b1 commit c6f1242

4 files changed

Lines changed: 59 additions & 23 deletions

File tree

README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,11 @@ fun <X> Connection.executeQuery(
6060
}
6161
```
6262

63-
#### Available via [jitpack](https://jitpack.io/#DataFabricRus/resource-iterator):
63+
#### Available via maven-central:
6464

6565
```kotlin
66-
repositories {
67-
...
68-
maven(url = "https://jitpack.io")
69-
}
70-
7166
dependencies {
72-
implementation("com.github.DataFabricRus.resource-iterator:resource-iterator-jvm:{{latest_version}}")
67+
implementation("io.github.datafabricrus:resource-iterator-jvm:{{latest_version}}")
7368
}
7469
```
7570

build.gradle.kts

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
import java.security.MessageDigest
2+
13
plugins {
24
kotlin("multiplatform")
35
id("maven-publish")
6+
id("org.jetbrains.dokka")
47
signing
58
}
69

710
group = "io.github.datafabricrus"
8-
version = "1.4-SNAPSHOT"
11+
version = "1.4"
912

1013
repositories {
1114
mavenCentral()
@@ -52,9 +55,49 @@ kotlin {
5255
}
5356
}
5457

58+
tasks.register<Jar>("javadocJar") {
59+
dependsOn("dokkaHtml")
60+
archiveClassifier.set("javadoc")
61+
from(buildDir.resolve("dokka/html"))
62+
}
63+
64+
tasks.named("publishToMavenLocal") {
65+
doLast {
66+
println("================================================")
67+
println("Generate MD5 files")
68+
println("================================================")
69+
val mavenLocalDir = file(repositories.mavenLocal().url)
70+
val artifactPathAsString = project.group.toString().replace('.', '/') + "/${project.name}"
71+
val artifactFile = mavenLocalDir.resolve(artifactPathAsString)
72+
val files = sequenceOf(artifactFile.toString(), "$artifactFile-jvm", "$artifactFile-js")
73+
.map { it + "/${version}" }
74+
.map { file(it) }
75+
.flatMap {
76+
it.walkTopDown()
77+
}
78+
.filter {
79+
it.isFile && (it.extension == "jar" || it.extension == "pom" || it.extension == "module")
80+
}
81+
files.forEach { file ->
82+
val md5 = MessageDigest.getInstance("MD5")
83+
.digest(file.readBytes()).joinToString("") { "%02x".format(it) }
84+
val sha1 = MessageDigest.getInstance("SHA-1")
85+
.digest(file.readBytes()).joinToString("") { "%02x".format(it) }
86+
87+
file.resolveSibling("${file.name}.md5").writeText(md5)
88+
file.resolveSibling("${file.name}.sha1").writeText(sha1)
89+
}
90+
}
91+
}
92+
5593
publishing {
5694
publications {
5795
withType<MavenPublication> {
96+
97+
artifact(tasks["javadocJar"]) {
98+
classifier = "javadoc"
99+
}
100+
58101
println("================================================")
59102
println("$groupId:$artifactId:$version")
60103
println("================================================")
@@ -83,23 +126,12 @@ publishing {
83126
}
84127
}
85128
}
86-
repositories {
87-
maven {
88-
name = "OSSRH"
89-
url = uri(
90-
if (version.toString().endsWith("SNAPSHOT"))
91-
"https://s01.oss.sonatype.org/content/repositories/snapshots/"
92-
else
93-
"https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
94-
)
95-
credentials {
96-
username = findProperty("ossrhUsername") as String? ?: System.getenv("OSSRH_USERNAME")
97-
password = findProperty("ossrhPassword") as String? ?: System.getenv("OSSRH_PASSWORD")
98-
}
99-
}
100-
}
101129
}
102130

103131
signing {
104132
sign(publishing.publications)
133+
}
134+
135+
tasks.withType<PublishToMavenLocal>().configureEach {
136+
dependsOn(tasks.withType<Sign>())
105137
}

gradle.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@ kotlin.code.style=official
33
kotlinVersion=1.9.22
44
# https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
55
junitVersion=5.10.2
6+
# https://plugins.gradle.org/plugin/org.jetbrains.dokka
7+
dokkaVersion=2.0.0
8+
org.jetbrains.dokka.experimental.gradle.pluginMode=V2EnabledWithHelpers
9+
signing.keyId=<secret>
10+
signing.password=<secret>
11+
signing.secretKeyRingFile=<path/secring.gpg>

settings.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ pluginManagement {
44
plugins {
55
plugins {
66
val kotlinVersion: String by settings
7+
val dokkaVersion: String by settings
8+
79
kotlin("multiplatform") version kotlinVersion
10+
id("org.jetbrains.dokka") version dokkaVersion
811
}
912
}
1013
}

0 commit comments

Comments
 (0)