Skip to content

Commit 811498c

Browse files
committed
feat(kotlin): add logic & metadata for publishing
1 parent 928f690 commit 811498c

File tree

4 files changed

+119
-2
lines changed

4 files changed

+119
-2
lines changed

kotlin/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Module Iroh
2+
3+
A toolkit for building distributed applications

kotlin/gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties
33

44
org.gradle.configuration-cache=true
5-
5+
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
6+
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true

kotlin/gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", vers
1313

1414
[plugins]
1515
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version = "2.0.20" }
16+
dokka = { id = "org.jetbrains.dokka", version = "2.0.0" }
17+

kotlin/lib/build.gradle.kts

Lines changed: 112 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*
32
* This file was generated by the Gradle 'init' task.
43
*
@@ -12,8 +11,15 @@ plugins {
1211

1312
// Apply the java-library plugin for API and implementation separation.
1413
`java-library`
14+
15+
`maven-publish`
16+
alias(libs.plugins.dokka)
17+
signing
1518
}
1619

20+
group = "computer.iroh"
21+
version = "0.31.0"
22+
1723
repositories {
1824
// Use Maven Central for resolving dependencies.
1925
mavenCentral()
@@ -35,6 +41,8 @@ dependencies {
3541

3642
// Apply a specific Java toolchain to ease working on different environments.
3743
java {
44+
withJavadocJar()
45+
withSourcesJar()
3846
toolchain {
3947
languageVersion = JavaLanguageVersion.of(21)
4048
}
@@ -57,3 +65,106 @@ tasks.named<Test>("test") {
5765
events("passed", "skipped", "failed")
5866
}
5967
}
68+
69+
val stagingDir = layout.buildDirectory.dir("staging")
70+
71+
signing {
72+
// Use property `signing.keyId` to pick GPG signing key
73+
// e.g. `./gradlew publish -Psigning.keyId=24875D73`
74+
// Or, place it in `~/.gradle/gradle.properties` for persistence.
75+
76+
useGpgCmd()
77+
sign(publishing.publications)
78+
}
79+
80+
dokka {
81+
moduleName = "Iroh"
82+
dokkaSourceSets.main {
83+
includes.from(rootProject.projectDir.resolve("README.md"))
84+
sourceLink {
85+
localDirectory = file("src/main/kotlin")
86+
remoteUrl("https://github.com/n0-computer/iroh-ffi/blob/main/kotlin/lib/src/main/kotlin")
87+
remoteLineSuffix.set("#L")
88+
}
89+
}
90+
pluginsConfiguration.html {
91+
footerMessage.set("© n0, inc.")
92+
}
93+
// Runs Dokka in the current Gradle process
94+
dokkaGeneratorIsolation = ClassLoaderIsolation()
95+
}
96+
97+
tasks.named("javadocJar", Jar::class) {
98+
dependsOn(tasks.dokkaGenerate)
99+
from(layout.buildDirectory.dir("dokka/html"))
100+
}
101+
102+
publishing {
103+
publications {
104+
register<MavenPublication>("maven") {
105+
groupId = project.group.toString()
106+
version = project.version.toString()
107+
artifactId = "iroh"
108+
109+
pom {
110+
// https://central.sonatype.org/publish/requirements/#required-pom-metadata
111+
112+
name = "Iroh"
113+
description = "A toolkit for building distributed applications"
114+
inceptionYear = "2025"
115+
url = "https://iroh.computer"
116+
117+
developers {
118+
developer {
119+
id = "number0"
120+
121+
organization = "number0"
122+
organizationUrl = "https://n0.computer"
123+
}
124+
}
125+
126+
licenses {
127+
license {
128+
name = "Apache License, Version 2.0"
129+
url = "https://opensource.org/license/apache-2-0"
130+
}
131+
license {
132+
name = "The MIT License"
133+
url = "https://opensource.org/licenses/MIT"
134+
}
135+
}
136+
137+
scm {
138+
connection = "scm:git:git://https://github.com/n0-computer/iroh-ffi.git"
139+
developerConnection = "scm:git:ssh://https://github.com/n0-computer/iroh-ffi.git"
140+
url = "https://github.com/n0-computer/iroh-ffi"
141+
}
142+
}
143+
144+
from(components["java"])
145+
}
146+
}
147+
148+
repositories {
149+
maven(uri(stagingDir)) {
150+
name = "staging"
151+
}
152+
}
153+
}
154+
155+
val cleanStagingDir by tasks.register<Delete>("cleanStagingDir") {
156+
delete(stagingDir)
157+
}
158+
159+
val zipStagingDir by tasks.register<Zip>("zipStagingDir") {
160+
from(stagingDir)
161+
archiveFileName.set("deploy.jar")
162+
}
163+
164+
tasks.named("publishMavenPublicationToStagingRepository") {
165+
dependsOn(cleanStagingDir)
166+
}
167+
168+
tasks.publish {
169+
finalizedBy(zipStagingDir)
170+
}

0 commit comments

Comments
 (0)