Skip to content

Commit 046e4cf

Browse files
authored
MOBILE-237: Implement central repository publishing requirements, bump Kotlin to 1.6.10 (#16)
1 parent 9276ffd commit 046e4cf

File tree

2 files changed

+75
-15
lines changed

2 files changed

+75
-15
lines changed

build.gradle.kts

Lines changed: 73 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
21
import org.jetbrains.kotlin.konan.properties.Properties
32

43
plugins {
54
kotlin("jvm") version Versions.KOTLIN
65
kotlin("plugin.serialization") version Versions.KOTLIN
6+
id("org.jetbrains.dokka") version Versions.KOTLIN
77
id("org.jlleitschuh.gradle.ktlint") version Versions.KTLINT
88
`maven-publish`
9-
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
9+
signing
10+
id("io.github.gradle-nexus.publish-plugin") version Versions.NEXUS_PUBLISH
1011
}
1112

1213
group = "eu.kevin"
@@ -26,11 +27,24 @@ dependencies {
2627
testImplementation("io.ktor:ktor-client-mock:${Versions.KTOR}")
2728
}
2829

29-
val compileKotlin: KotlinCompile by tasks
30+
tasks {
31+
compileKotlin {
32+
kotlinOptions {
33+
jvmTarget = "1.8"
34+
freeCompilerArgs = freeCompilerArgs + "-Xopt-in=kotlin.RequiresOptIn"
35+
}
36+
}
37+
38+
create<Jar>("dokkaJar") {
39+
archiveClassifier.set("javadoc")
40+
from(dokkaJavadoc)
41+
dependsOn(dokkaJavadoc)
42+
}
3043

31-
compileKotlin.kotlinOptions {
32-
jvmTarget = "1.8"
33-
freeCompilerArgs = freeCompilerArgs + "-Xopt-in=kotlin.RequiresOptIn"
44+
create<Jar>("sourcesJar") {
45+
archiveClassifier.set("sources")
46+
from(sourceSets["main"].allSource)
47+
}
3448
}
3549

3650
tasks.test {
@@ -50,26 +64,71 @@ fun Project.configureCodeStyleRules() = configure<org.jlleitschuh.gradle.ktlint.
5064
)
5165
}
5266

53-
configure<PublishingExtension> {
54-
publications {
55-
create<MavenPublication>("kotlin") {
56-
from(components["kotlin"])
57-
}
58-
}
59-
}
60-
6167
val props = File("./local.properties").let { file ->
6268
Properties().apply {
6369
if (file.exists()) {
6470
load(file.inputStream())
6571
} else {
6672
setProperty("ossrhUsername", System.getenv("OSSRH_USERNAME"))
6773
setProperty("ossrhPassword", System.getenv("OSSRH_PASSWORD"))
74+
setProperty("mavenSigningKeyId", System.getenv("MAVEN_SIGNING_KEY_ID"))
75+
setProperty("mavenSigningKey", System.getenv("MAVEN_SIGNING_KEY"))
76+
setProperty("mavenSigningKeyPassword", System.getenv("MAVEN_SIGNING_KEY_PASSWORD"))
6877
setProperty("sdkVersion", System.getenv("SDK_RELEASE_VERSION"))
6978
}
7079
}
7180
}
7281

82+
configure<PublishingExtension> {
83+
publications {
84+
create<MavenPublication>("kotlin") {
85+
from(components["kotlin"])
86+
87+
artifact(tasks["sourcesJar"])
88+
artifact(tasks["dokkaJar"])
89+
version = props.getProperty("sdkVersion")
90+
91+
pom {
92+
name.set("kevin. JVM")
93+
description.set("JVM client implementing kevin. platform API")
94+
url.set("https://github.com/getkevin/kevin-jvm")
95+
96+
licenses {
97+
license {
98+
name.set("MIT License")
99+
url.set("http://www.opensource.org/licenses/mit-license.php")
100+
}
101+
}
102+
103+
developers {
104+
developer {
105+
id.set("mobile-kevin-dev")
106+
name.set("Kevin mobile developers")
107+
email.set("[email protected]")
108+
}
109+
}
110+
111+
scm {
112+
connection.set("scm:git:github.com/getkevin/kevin-jvm.git")
113+
developerConnection.set("scm:git:ssh://github.com/getkevin/kevin-jvm.git")
114+
url.set("https://github.com/getkevin/kevin-jvm/tree/master")
115+
}
116+
}
117+
}
118+
}
119+
}
120+
121+
signing {
122+
isRequired = true
123+
useInMemoryPgpKeys(
124+
props.getProperty("mavenSigningKeyId"),
125+
props.getProperty("mavenSigningKey"),
126+
props.getProperty("mavenSigningKeyPassword")
127+
)
128+
sign(tasks["sourcesJar"], tasks["dokkaJar"])
129+
sign(publishing.publications["kotlin"])
130+
}
131+
73132
nexusPublishing {
74133
repositories {
75134
sonatype {
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
object Versions {
2-
const val KOTLIN = "1.5.31"
2+
const val KOTLIN = "1.6.10"
33
const val KTOR = "1.6.5"
44
const val KTLINT = "10.2.0"
5+
const val NEXUS_PUBLISH = "1.1.0"
56
}

0 commit comments

Comments
 (0)