Skip to content

Commit

Permalink
resource-iterator: change build.gradle.kts for publishing to maven-ce…
Browse files Browse the repository at this point in the history
…ntral
  • Loading branch information
sszuev committed Dec 19, 2024
1 parent 5e108b1 commit c6f1242
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 23 deletions.
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,11 @@ fun <X> Connection.executeQuery(
}
```

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

```kotlin
repositories {
...
maven(url = "https://jitpack.io")
}

dependencies {
implementation("com.github.DataFabricRus.resource-iterator:resource-iterator-jvm:{{latest_version}}")
implementation("io.github.datafabricrus:resource-iterator-jvm:{{latest_version}}")
}
```

Expand Down
64 changes: 48 additions & 16 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import java.security.MessageDigest

plugins {
kotlin("multiplatform")
id("maven-publish")
id("org.jetbrains.dokka")
signing
}

group = "io.github.datafabricrus"
version = "1.4-SNAPSHOT"
version = "1.4"

repositories {
mavenCentral()
Expand Down Expand Up @@ -52,9 +55,49 @@ kotlin {
}
}

tasks.register<Jar>("javadocJar") {
dependsOn("dokkaHtml")
archiveClassifier.set("javadoc")
from(buildDir.resolve("dokka/html"))
}

tasks.named("publishToMavenLocal") {
doLast {
println("================================================")
println("Generate MD5 files")
println("================================================")
val mavenLocalDir = file(repositories.mavenLocal().url)
val artifactPathAsString = project.group.toString().replace('.', '/') + "/${project.name}"
val artifactFile = mavenLocalDir.resolve(artifactPathAsString)
val files = sequenceOf(artifactFile.toString(), "$artifactFile-jvm", "$artifactFile-js")
.map { it + "/${version}" }
.map { file(it) }
.flatMap {
it.walkTopDown()
}
.filter {
it.isFile && (it.extension == "jar" || it.extension == "pom" || it.extension == "module")
}
files.forEach { file ->
val md5 = MessageDigest.getInstance("MD5")
.digest(file.readBytes()).joinToString("") { "%02x".format(it) }
val sha1 = MessageDigest.getInstance("SHA-1")
.digest(file.readBytes()).joinToString("") { "%02x".format(it) }

file.resolveSibling("${file.name}.md5").writeText(md5)
file.resolveSibling("${file.name}.sha1").writeText(sha1)
}
}
}

publishing {
publications {
withType<MavenPublication> {

artifact(tasks["javadocJar"]) {
classifier = "javadoc"
}

println("================================================")
println("$groupId:$artifactId:$version")
println("================================================")
Expand Down Expand Up @@ -83,23 +126,12 @@ publishing {
}
}
}
repositories {
maven {
name = "OSSRH"
url = uri(
if (version.toString().endsWith("SNAPSHOT"))
"https://s01.oss.sonatype.org/content/repositories/snapshots/"
else
"https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
)
credentials {
username = findProperty("ossrhUsername") as String? ?: System.getenv("OSSRH_USERNAME")
password = findProperty("ossrhPassword") as String? ?: System.getenv("OSSRH_PASSWORD")
}
}
}
}

signing {
sign(publishing.publications)
}

tasks.withType<PublishToMavenLocal>().configureEach {
dependsOn(tasks.withType<Sign>())
}
6 changes: 6 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ kotlin.code.style=official
kotlinVersion=1.9.22
# https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
junitVersion=5.10.2
# https://plugins.gradle.org/plugin/org.jetbrains.dokka
dokkaVersion=2.0.0
org.jetbrains.dokka.experimental.gradle.pluginMode=V2EnabledWithHelpers
signing.keyId=<secret>
signing.password=<secret>
signing.secretKeyRingFile=<path/secring.gpg>
3 changes: 3 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ pluginManagement {
plugins {
plugins {
val kotlinVersion: String by settings
val dokkaVersion: String by settings

kotlin("multiplatform") version kotlinVersion
id("org.jetbrains.dokka") version dokkaVersion
}
}
}

0 comments on commit c6f1242

Please sign in to comment.