-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
223 lines (188 loc) · 6.42 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
223 lines (188 loc) · 6.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
plugins {
kotlin("jvm") version "1.9.22"
kotlin("plugin.serialization") version "1.9.22"
`maven-publish`
id("pl.allegro.tech.build.axion-release") version "1.17.0"
id("com.vanniktech.maven.publish") version "0.28.0"
}
group = "dev.insforge"
// Allow version override via -Pversion=x.y.z, otherwise use axion-release
version = if (project.hasProperty("version") && project.property("version") != "unspecified") {
project.property("version").toString()
} else {
scmVersion.version
}
// Configure axion-release plugin
scmVersion {
tag {
prefix.set("v")
}
versionIncrementer("incrementPatch")
checks {
// Disable remote branch tracking check
aheadOfRemote.set(false)
}
}
repositories {
mavenCentral()
google()
}
dependencies {
// Kotlin stdlib
implementation("org.jetbrains.kotlin:kotlin-stdlib")
// Coroutines
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
// Serialization
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.2")
// Logging - Napier (cross-platform: JVM/Android/iOS)
api("io.github.aakira:napier:2.7.1")
// HTTP Client (Ktor)
// OkHttp is the default engine - works on both JVM and Android
api("io.ktor:ktor-client-core:2.3.7")
api("io.ktor:ktor-client-okhttp:2.3.7")
implementation("io.ktor:ktor-client-content-negotiation:2.3.7")
implementation("io.ktor:ktor-serialization-kotlinx-json:2.3.7")
implementation("io.ktor:ktor-client-logging:2.3.7")
// Socket.IO client for Realtime (InsForge uses Socket.IO, not raw WebSocket)
implementation("io.socket:socket.io-client:2.1.1")
// Testing
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3")
testImplementation("io.ktor:ktor-client-mock:2.3.7")
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
// Generate InsforgeVersion.kt with version from build.gradle.kts
val generateVersionFile by tasks.registering {
val outputDir = file("$buildDir/generated/source/version/main/kotlin")
val versionFile = file("$outputDir/io/insforge/InsforgeVersion.kt")
inputs.property("version", version)
outputs.file(versionFile)
doLast {
outputDir.mkdirs()
versionFile.parentFile.mkdirs()
versionFile.writeText(
"""
|package dev.insforge
|
|/**
| * SDK version information (auto-generated from build.gradle.kts)
| */
|object InsforgeVersion {
| const val VERSION = "$version"
| const val USER_AGENT = "InsForge-Kotlin/${'$'}VERSION"
|}
""".trimMargin()
)
}
}
// Add generated source to main source set
kotlin {
sourceSets {
main {
kotlin.srcDir("$buildDir/generated/source/version/main/kotlin")
}
}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
dependsOn(generateVersionFile)
kotlinOptions {
jvmTarget = "11"
freeCompilerArgs = listOf("-opt-in=kotlin.RequiresOptIn")
}
}
tasks.withType<Test>().configureEach {
useJUnitPlatform {
// `test` is our unit-test task in CI; integration tests run via `integrationTest`.
if (name == "test") {
excludeTags("integration")
}
}
// Show test output including HTTP logs
testLogging {
showStandardStreams = true
events("passed", "skipped", "failed")
}
}
val integrationTest by tasks.registering(Test::class) {
description = "Runs integration tests that depend on external services"
group = LifecycleBasePlugin.VERIFICATION_GROUP
testClassesDirs = sourceSets["test"].output.classesDirs
classpath = sourceSets["test"].runtimeClasspath
maxHeapSize = "512m"
useJUnitPlatform {
includeTags("integration")
}
testLogging {
showStandardStreams = true
events("passed", "skipped", "failed")
}
shouldRunAfter(tasks.named("test"))
}
// Ensure all Jar tasks depend on generateVersionFile
tasks.withType<Jar>().configureEach {
dependsOn(generateVersionFile)
}
// Explicitly configure kotlinSourcesJar task created by vanniktech plugin
tasks.matching { it.name == "kotlinSourcesJar" }.configureEach {
dependsOn(generateVersionFile)
}
// GitHub Packages repository configuration
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/InsForge/insforge-kotlin")
credentials {
username = System.getenv("GITHUB_ACTOR") ?: project.findProperty("gpr.user") as String? ?: ""
password = System.getenv("GITHUB_TOKEN") ?: project.findProperty("gpr.token") as String? ?: ""
}
}
}
}
// Maven Central publishing via Vanniktech plugin
mavenPublishing {
publishToMavenCentral(com.vanniktech.maven.publish.SonatypeHost.CENTRAL_PORTAL)
signAllPublications()
coordinates(
groupId = "dev.insforge",
artifactId = "insforge-kotlin",
version = version.toString()
)
pom {
name.set("InsForge Kotlin SDK")
description.set("Official Kotlin SDK for InsForge Backend-as-a-Service")
url.set("https://github.com/InsForge/insforge-kotlin")
inceptionYear.set("2025")
licenses {
license {
name.set("MIT License")
url.set("https://opensource.org/licenses/MIT")
}
}
developers {
developer {
id.set("insforge")
name.set("InsForge Team")
email.set("support@insforge.dev")
}
}
scm {
connection.set("scm:git:git://github.com/InsForge/insforge-kotlin.git")
developerConnection.set("scm:git:ssh://github.com/InsForge/insforge-kotlin.git")
url.set("https://github.com/InsForge/insforge-kotlin")
}
}
}
// Note: GPG signing is handled by the vanniktech maven-publish plugin via environment variables:
// - ORG_GRADLE_PROJECT_signingInMemoryKeyId
// - ORG_GRADLE_PROJECT_signingInMemoryKey
// - ORG_GRADLE_PROJECT_signingInMemoryKeyPassword
// Fix implicit dependency issues between signing and jar tasks
tasks.configureEach {
if (name.startsWith("sign")) {
dependsOn(tasks.withType<Jar>())
}
}