Skip to content

Commit 05abbfe

Browse files
committed
Publication scripts
1 parent 0fbcad3 commit 05abbfe

File tree

9 files changed

+133
-67
lines changed

9 files changed

+133
-67
lines changed

build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@ plugins {
44
alias(libs.plugins.kotlin.jvm) apply false
55
alias(libs.plugins.kotlin.multiplatform) apply false
66
alias(libs.plugins.kotlin.serialization) apply false
7+
}
8+
9+
allprojects {
10+
group = "io.github.trueangle"
11+
version = "0.0.1"
712
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
gradlePluginPortal()
7+
}
8+
9+
kotlin {
10+
jvmToolchain(17)
11+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import org.gradle.api.publish.maven.MavenPublication
2+
import org.gradle.api.tasks.bundling.Jar
3+
import org.gradle.kotlin.dsl.`maven-publish`
4+
import org.gradle.kotlin.dsl.signing
5+
import java.util.*
6+
7+
plugins {
8+
`maven-publish`
9+
signing
10+
}
11+
12+
ext["signing.keyId"] = null
13+
ext["signing.password"] = null
14+
ext["signing.secretKeyRingFile"] = null
15+
ext["ossrhUsername"] = null
16+
ext["ossrhPassword"] = null
17+
18+
val secretPropsFile = project.rootProject.file("local.properties")
19+
if (secretPropsFile.exists()) {
20+
secretPropsFile.reader().use {
21+
Properties().apply {
22+
load(it)
23+
}
24+
}.onEach { (name, value) ->
25+
ext[name.toString()] = value
26+
}
27+
} else {
28+
ext["signing.keyId"] = System.getenv("SIGNING_KEY_ID")
29+
ext["signing.password"] = System.getenv("SIGNING_PASSWORD")
30+
ext["signing.secretKeyRingFile"] = System.getenv("SIGNING_SECRET_KEY_RING_FILE")
31+
ext["ossrhUsername"] = System.getenv("OSSRH_USERNAME")
32+
ext["ossrhPassword"] = System.getenv("OSSRH_PASSWORD")
33+
}
34+
35+
val javadocJar by tasks.registering(Jar::class) {
36+
archiveClassifier.set("javadoc")
37+
}
38+
39+
fun getExtraString(name: String) = ext[name]?.toString()
40+
41+
publishing {
42+
repositories {
43+
maven {
44+
name = "sonatype"
45+
val releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
46+
val snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
47+
val url = if (version.toString().endsWith("SNAPSHOT")) {
48+
uri(snapshotsRepoUrl)
49+
} else {
50+
uri(releasesRepoUrl)
51+
}
52+
53+
setUrl(url)
54+
credentials {
55+
username = getExtraString("ossrhUsername")
56+
password = getExtraString("ossrhPassword")
57+
}
58+
}
59+
}
60+
61+
publications.withType<MavenPublication> {
62+
artifact(javadocJar.get())
63+
64+
pom {
65+
name.set("Kotlin-native-aws-lambda-runtime")
66+
description.set("A Kotlin Native Runtime for AWS Lambda")
67+
url.set("https://github.com/trueangle/kotlin-native-aws-lambda-runtime")
68+
69+
licenses {
70+
license {
71+
name.set("Apache-2.0 license")
72+
url.set("https://opensource.org/license/apache-2-0/")
73+
}
74+
}
75+
developers {
76+
developer {
77+
id.set("trueangle")
78+
name.set("Viacheslav Ivanovichev")
79+
email.set("s.ivanovichev@gmail.com")
80+
}
81+
}
82+
scm {
83+
url.set("https://github.com/trueangle/kotlin-native-aws-lambda-runtime")
84+
connection.set("scm:git:git://github.com/trueangle/kotlin-native-aws-lambda-runtime.git")
85+
developerConnection.set("scm:git:git://github.com/trueangle/kotlin-native-aws-lambda-runtime.git")
86+
}
87+
}
88+
}
89+
}
90+
91+
// https://youtrack.jetbrains.com/issue/KT-46466
92+
tasks.withType<AbstractPublishToMaven>().configureEach {
93+
val signingTasks = tasks.withType<Sign>()
94+
mustRunAfter(signingTasks)
95+
}
96+
97+
signing {
98+
sign(publishing.publications)
99+
}

lambda-events/build.gradle.kts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@ plugins {
22
alias(libs.plugins.kotlin.multiplatform)
33
alias(libs.plugins.kotlin.serialization)
44
alias(libs.plugins.kotlinx.resources)
5+
id("convention.publication")
56
}
67

78
kotlin {
8-
val isArm64 = System.getProperty("os.arch") == "aarch64"
9-
val hostOs = System.getProperty("os.name")
10-
val isMingwX64 = hostOs.startsWith("Windows")
11-
val nativeTarget = when {
12-
hostOs == "Mac OS X" -> if(isArm64) macosArm64() else macosX64()
13-
hostOs == "Linux" -> if (isArm64) linuxArm64() else linuxX64()
14-
isMingwX64 -> mingwX64("native")
15-
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
16-
}
9+
macosArm64()
10+
macosX64()
11+
linuxArm64()
12+
linuxX64()
13+
mingwX64()
1714

1815
sourceSets {
1916
commonMain.dependencies {

lambda-events/src/commonMain/kotlin/io/github/trueangle/knative/lambda/runtime/events/ALBTargetGroupRequest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import kotlinx.serialization.SerialName
44
import kotlinx.serialization.Serializable
55

66
@Serializable
7-
data class ALBTargetGroupRequest<T>(
7+
data class ALBTargetGroupRequest(
88
@SerialName("httpMethod") val httpMethod: String,
99
@SerialName("path") val path: String,
1010
@SerialName("queryStringParameters") val queryStringParameters: Map<String, String>,
1111
@SerialName("headers") val headers: Map<String, String>?,
1212
@SerialName("multiValueHeaders") val multiValueHeaders: Map<String, String>?,
1313
@SerialName("requestContext") val requestContext: Context,
1414
@SerialName("isBase64Encoded") val isBase64Encoded: Boolean,
15-
@SerialName("body") val body: T?
15+
@SerialName("body") val body: String?
1616
) {
1717
@Serializable
1818
data class Context(

lambda-events/src/commonMain/kotlin/io/github/trueangle/knative/lambda/runtime/events/LambdaGatewayProxyEvent.kt

Lines changed: 0 additions & 43 deletions
This file was deleted.

lambda-events/src/commonMain/kotlin/io/github/trueangle/knative/lambda/runtime/events/apigateway/APIGatewayProxy.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import kotlinx.serialization.Serializable
44
import kotlinx.serialization.SerialName
55

66
@Serializable
7-
data class APIGatewayProxy<T>(
7+
data class APIGatewayProxy(
88
@SerialName("version") val version: String,
99
@SerialName("resource") val resource: String?,
1010
@SerialName("path") val path: String?,
@@ -16,7 +16,7 @@ data class APIGatewayProxy<T>(
1616
@SerialName("pathParameters") val pathParameters: Map<String, String>?,
1717
@SerialName("stageVariables") val stageVariables: Map<String, String>?,
1818
@SerialName("requestContext") val requestContext: ProxyRequestContext,
19-
@SerialName("body") val body: T?,
19+
@SerialName("body") val body: String?,
2020
@SerialName("isBase64Encoded") val isBase64Encoded: Boolean
2121
) {
2222
@Serializable

lambda-runtime/build.gradle.kts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,19 @@ plugins {
55
alias(libs.plugins.kotlin.serialization)
66
alias(libs.plugins.mokkery)
77
alias(libs.plugins.kotlinx.resources)
8+
id("convention.publication")
89
}
910

1011
kotlin {
11-
val isArm64 = System.getProperty("os.arch") == "aarch64"
12-
val hostOs = System.getProperty("os.name")
13-
val isMingwX64 = hostOs.startsWith("Windows")
14-
val nativeTarget = when {
15-
hostOs == "Mac OS X" -> if (isArm64) macosArm64() else macosX64()
16-
hostOs == "Linux" -> if (isArm64) linuxArm64() else linuxX64()
17-
isMingwX64 -> mingwX64("native")
18-
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
19-
}
12+
macosArm64()
13+
macosX64()
14+
linuxArm64()
15+
linuxX64()
16+
mingwX64()
2017

2118
sourceSets {
2219
commonMain.dependencies {
20+
implementation(projects.lambdaEvents)
2321
implementation(libs.ktor.client.core)
2422
implementation(libs.kotlin.serialization.json)
2523
implementation(libs.kotlin.io.core)
@@ -31,7 +29,6 @@ kotlin {
3129
}
3230

3331
nativeTest.dependencies {
34-
implementation(projects.lambdaEvents)
3532
implementation(libs.kotlin.test)
3633
implementation(libs.kotlin.coroutines.test)
3734
implementation(libs.ktor.client.mock)

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ dependencyResolutionManagement {
2727
mavenCentral()
2828
}
2929
}
30-
30+
includeBuild("convention-plugins")
3131
include(":lambda-runtime")
3232
include(":sample")
3333
include(":lambda-events")

0 commit comments

Comments
 (0)