Skip to content

Commit 9be9392

Browse files
committed
chore: kotlin native build fixes
1 parent f42e1a6 commit 9be9392

File tree

14 files changed

+68
-108
lines changed

14 files changed

+68
-108
lines changed

README.md

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -170,42 +170,38 @@ $ actionlint
170170
'theme': 'base'
171171
}
172172
}%%
173+
173174
graph LR
174-
subgraph backend
175-
jvm
176-
native
177-
end
178-
subgraph web
179-
js
180-
wasm
181-
end
182-
subgraph compose
183-
desktop
184-
compose-web
185-
end
186-
subgraph dep-mgmt
187-
bom
188-
catalog
189-
end
190-
subgraph meta
191-
compiler
192-
ksp
193-
end
194-
subgraph compiler
195-
compiler
196-
plugin
197-
end
198-
subgraph ksp
199-
ksp
200-
processor
201-
end
202-
plugin --> shared
203-
web --> shared
204-
desktop --> shared
205-
native --> shared
206-
processor --> shared
207-
jvm --> shared
208-
jvm --> js
209-
jvm --> wasm
210-
benchmark --> shared
175+
subgraph backend
176+
jvm
177+
data
178+
native
179+
end
180+
subgraph meta
181+
compiler
182+
ksp
183+
end
184+
subgraph compiler
185+
compiler
186+
plugin
187+
end
188+
subgraph ksp
189+
ksp
190+
processor
191+
end
192+
subgraph web
193+
wasm
194+
js
195+
end
196+
plugin --> shared
197+
wasm --> shared
198+
benchmark --> shared
199+
data --> shared
200+
native --> shared
201+
processor --> shared
202+
jvm --> shared
203+
jvm --> data
204+
jvm --> js
205+
jvm --> wasm
206+
js --> shared
211207
```

backend/README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33
```bash
44
# JVM
55
$ ./gradlew :backend:jvm:run
6-
7-
# Native
8-
$ ./gradlew :backend:native:macOsUniversalBinary
9-
10-
# Container
11-
$ ./gradlew :backend:native:jibDockerBuild
12-
$ docker run -it --rm sureshg/native
136
```
147

158
### Misc

backend/jvm/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,16 @@ exposedCodeGeneratorConfig { outputDirectory.set(file("src/main/kotlin/dev/sures
3333
jib {
3434
from {
3535
image = "openjdk:${javaVersion.get().majorVersion}-slim"
36+
3637
platforms {
3738
platform {
3839
architecture = "arm64"
3940
os = "linux"
4041
}
42+
platform {
43+
architecture = "arm64"
44+
os = "linux"
45+
}
4146
}
4247
}
4348

backend/native/build.gradle.kts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import com.github.ajalt.mordant.rendering.TextColors
22
import com.google.cloud.tools.jib.gradle.extension.nativeimage.JibNativeImageExtension
3+
import common.githubRepo
34
import common.githubUser
45
import org.gradle.internal.os.OperatingSystem
56
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
@@ -37,10 +38,6 @@ jib {
3738
architecture = "amd64"
3839
os = "linux"
3940
}
40-
// platform {
41-
// architecture = "arm64"
42-
// os = "linux"
43-
// }
4441
}
4542
}
4643

@@ -55,7 +52,23 @@ jib {
5552
properties = mapOf("imageName" to "app")
5653
}
5754
}
58-
container { mainClass = "MainKt" }
55+
56+
container {
57+
ports = listOf("8080", "9898")
58+
args = listOf(project.name, project.version.toString())
59+
labels =
60+
mapOf(
61+
"maintainer" to project.githubUser,
62+
"org.opencontainers.image.authors" to project.githubUser,
63+
"org.opencontainers.image.title" to project.name,
64+
"org.opencontainers.image.description" to "🐳 ${project.description}",
65+
"org.opencontainers.image.version" to project.version.toString(),
66+
"org.opencontainers.image.vendor" to project.githubUser,
67+
"org.opencontainers.image.url" to project.githubRepo,
68+
"org.opencontainers.image.source" to project.githubRepo,
69+
"org.opencontainers.image.licenses" to "Apache-2.0")
70+
mainClass = "MainKt"
71+
}
5972
}
6073

6174
// Workaround for Jib

gradle/build-logic/src/main/kotlin/common/MultiPlatformExtns.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ fun KotlinMultiplatformExtension.commonTarget() {
5050
api(libs.kotlinx.html)
5151
api(libs.kotlin.bignum)
5252
api(libs.kotlin.bignum.serialization)
53-
// TODO: Remove this once Ktor get WASM support
5453
if (project.name != "wasm") {
5554
api(libs.ktor.client.core)
5655
api(libs.ktor.client.content.negotiation)

gradle/build-logic/src/main/kotlin/common/ProjectExtns.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ fun Project.jvmArguments(appRun: Boolean = false, headless: Boolean = true) = bu
251251
// "-Djdk.lang.Process.launchMechanism=vfork",
252252
// "-Djdk.tls.maxCertificateChainLength=10",
253253
// "-Djdk.tls.maxHandshakeMessageSize=32768",
254-
// "-Djdk.virtualThreadScheduler.parallelism=",
254+
// "-Djdk.virtualThreadScheduler.parallelism=10",
255255
// "-Djdk.virtualThreadScheduler.maxPoolSize=256",
256256
// "--add-exports=java.management/sun.management=ALL-UNNAMED",
257257
// "--add-exports=jdk.attach/sun.tools.attach=ALL-UNNAMED",
@@ -418,7 +418,7 @@ fun LanguageSettingsBuilder.configureKotlinLang() {
418418
optIn("kotlin.ExperimentalMultiplatform")
419419
optIn("kotlin.js.ExperimentalJsExport")
420420
optIn("kotlin.experimental.ExperimentalNativeApi")
421-
// optIn("kotlinx.cinterop.ExperimentalForeignApi")
421+
optIn("kotlinx.cinterop.ExperimentalForeignApi")
422422
// optIn("org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi")
423423
}
424424

gradle/build-logic/src/main/kotlin/common/Repo.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,10 @@ object Repo {
1212

1313
const val YARN = "https://github.com/yarnpkg/yarn/releases/download/"
1414

15-
const val KOTLIN_NATIVE = "https://download.jetbrains.com/kotlin/native/builds/"
16-
1715
const val COMPOSE_MULTIPLATFORM_DEV = "https://maven.pkg.jetbrains.space/public/p/compose/dev"
1816

1917
const val KOBWEB = "https://us-central1-maven.pkg.dev/varabyte-repos/public"
2018

21-
const val JETPACK_COMPOSE = "https://androidx.dev/storage/compose-compiler/repository"
22-
23-
const val KOTLIN_WASM_EXPERIMENTAL =
24-
"https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental"
25-
2619
/** The GitHub username */
2720
val GITHUB_USER = System.getenv("GITHUB_USER").orEmpty()
2821

gradle/build-logic/src/main/kotlin/plugins/kotlin.jvm.gradle.kts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@ ksp {
6767

6868
// kotlinPowerAssert { functions = listOf("kotlin.assert", "kotlin.test.assertTrue") }
6969

70-
redacted {
71-
enabled = false
72-
replacementString = ""
73-
}
70+
redacted { replacementString = "" }
7471

7572
kover {
7673
// useJacoco()

gradle/build-logic/src/main/kotlin/plugins/kotlin.mpp.gradle.kts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,7 @@ atomicfu {
6969

7070
// kotlinPowerAssert { functions = listOf("kotlin.assert", "kotlin.test.assertTrue") }
7171

72-
redacted {
73-
enabled = false
74-
replacementString = ""
75-
}
72+
redacted { replacementString = "" }
7673

7774
kover {
7875
// useJacoco()

gradle/build-logic/src/main/kotlin/settings/repos.settings.gradle.kts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ plugins {
5151
dependencyResolutionManagement {
5252
repositories {
5353
mavenCentral()
54-
kotlinNative()
5554
nodeJS()
5655
yarn()
5756
composeMultiplatformDev()
@@ -60,34 +59,6 @@ dependencyResolutionManagement {
6059
repositoriesMode = RepositoriesMode.PREFER_SETTINGS
6160
}
6261

63-
// Workaround for https://youtrack.jetbrains.com/issue/KT-51379
64-
fun RepositoryHandler.kotlinNative() {
65-
exclusiveContent {
66-
forRepository {
67-
ivy(Repo.KOTLIN_NATIVE) {
68-
name = "Kotlin Native"
69-
patternLayout {
70-
// Download URLs:
71-
// https://download.jetbrains.com/kotlin/native/builds/releases/1.9.20/macos-aarch64/kotlin-native-prebuilt-macos-aarch64-1.9.20.tar.gz
72-
listOf(
73-
"macos-x86_64",
74-
"macos-aarch64",
75-
"linux-x86_64",
76-
"windows-x86_64",
77-
)
78-
.forEach { os ->
79-
listOf("dev", "releases").forEach { stage ->
80-
artifact("$stage/[revision]/$os/[artifact]-[revision].[ext]")
81-
}
82-
}
83-
}
84-
metadataSources { artifact() }
85-
}
86-
}
87-
filter { includeModuleByRegex(".*", ".*kotlin-native-prebuilt.*") }
88-
}
89-
}
90-
9162
fun RepositoryHandler.nodeJS() {
9263
exclusiveContent {
9364
forRepository {

0 commit comments

Comments
 (0)