diff --git a/gradle.properties b/gradle.properties index b0c6bd4..18434fa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -28,4 +28,10 @@ android.useAndroidX=true android.nonTransitiveRClass=true # other -kotlin.native.cacheKind.linuxX64=none \ No newline at end of file +kotlin.native.cacheKind.linuxX64=none + +# Workaround: Ensure Gradle uses a JDK with `jlink` available for AGP's JDK image transform. +# On this environment, the system JDK 21 installation lacks `jlink`, causing +# :lynglib:androidJdkImage to fail. Point Gradle to JDK 17 which includes `jlink`. +# This affects only the JDK Gradle runs with; Kotlin/JVM target remains compatible. +org.gradle.java.home=/usr/lib/jvm/java-17-openjdk-amd64 \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 55677c8..b6db897 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] agp = "8.5.2" clikt = "5.0.3" -kotlin = "2.2.20" +kotlin = "2.2.21" android-minSdk = "24" android-compileSdk = "34" kotlinx-coroutines = "1.10.2" diff --git a/lyng/build.gradle.kts b/lyng/build.gradle.kts index 1533746..36c72ab 100644 --- a/lyng/build.gradle.kts +++ b/lyng/build.gradle.kts @@ -16,7 +16,7 @@ */ plugins { - kotlin("multiplatform") version "2.2.20" + alias(libs.plugins.kotlinMultiplatform) } group = "net.sergeych" diff --git a/lynglib/build.gradle.kts b/lynglib/build.gradle.kts index a22c1a1..e946598 100644 --- a/lynglib/build.gradle.kts +++ b/lynglib/build.gradle.kts @@ -23,21 +23,13 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget group = "net.sergeych" version = "1.0.0-SNAPSHOT" -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0") - classpath("com.codingfeline.buildkonfig:buildkonfig-gradle-plugin:latest_version") - } -} +// Removed legacy buildscript classpath declarations; plugins are applied via the plugins DSL below plugins { alias(libs.plugins.kotlinMultiplatform) alias(libs.plugins.androidLibrary) // alias(libs.plugins.vanniktech.mavenPublish) - kotlin("plugin.serialization") version "2.1.0" + kotlin("plugin.serialization") version "2.2.21" id("com.codingfeline.buildkonfig") version "0.17.1" `maven-publish` } @@ -84,9 +76,10 @@ kotlin { all { languageSettings.optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") languageSettings.optIn("kotlin.ExperimentalUnsignedTypes") - languageSettings.optIn("kotlin.coroutines.DelicateCoroutinesApi") + // Correct opt-in markers for coroutines + languageSettings.optIn("kotlinx.coroutines.DelicateCoroutinesApi") languageSettings.optIn("kotlin.contracts.ExperimentalContracts") - languageSettings.optIn("kotlinx.coroutines.flow.DelicateCoroutinesApi") + languageSettings.optIn("kotlinx.coroutines.FlowPreview") } val commonMain by getting { diff --git a/settings.gradle.kts b/settings.gradle.kts index af352f8..c375a0a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -36,3 +36,4 @@ dependencyResolutionManagement { rootProject.name = "lyng" include(":lynglib") include(":lyng") +include(":site") diff --git a/site/build.gradle.kts b/site/build.gradle.kts new file mode 100644 index 0000000..82998ed --- /dev/null +++ b/site/build.gradle.kts @@ -0,0 +1,60 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/* + * Compose HTML (JS-only) SPA module + */ + +plugins { + alias(libs.plugins.kotlinMultiplatform) + // Compose compiler plugin for Kotlin 2.2.21 (matches version catalog) + id("org.jetbrains.kotlin.plugin.compose") version "2.2.21" + // Compose Multiplatform plugin for convenient dependencies (compose.html.core, etc.) + id("org.jetbrains.compose") version "1.9.3" +} + +kotlin { + js(IR) { + browser { + commonWebpackConfig { + // Enable CSS handling + cssSupport { + enabled.set(true) + } + // Ensure predictable output name so we can reference it from index.html + outputFileName = "site.js" + } + } + binaries.executable() + } + + sourceSets { + val jsMain by getting { + dependencies { + implementation("org.jetbrains.compose.runtime:runtime:1.9.3") + implementation("org.jetbrains.compose.html:html-core:1.9.3") + } + } + val jsTest by getting { + dependencies { + implementation(libs.kotlin.test) + } + } + } +} + +// Optional: configure toolchain if needed by the project; uses root Kotlin version from version catalog \ No newline at end of file diff --git a/site/src/jsMain/kotlin/Main.kt b/site/src/jsMain/kotlin/Main.kt new file mode 100644 index 0000000..ebeb94d --- /dev/null +++ b/site/src/jsMain/kotlin/Main.kt @@ -0,0 +1,47 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import org.jetbrains.compose.web.dom.* +import org.jetbrains.compose.web.renderComposable + +fun main() { + renderComposable(rootElementId = "root") { + // Minimal SPA shell + Div({ classes("container", "py-4") }) { + H1({ classes("display-6", "mb-3") }) { Text("Compose HTML SPA") } + P({ classes("lead") }) { + Text("This static site is powered by Compose for Web (JS-only) and Bootstrap 5.3.") + } + + Hr() + + // Example of interactive state to show SPA behavior + var count by remember { mutableStateOf(0) } + Div({ classes("d-flex", "gap-2", "align-items-center") }) { + Button(attrs = { + classes("btn", "btn-primary") + onClick { count++ } + }) { Text("Increment") } + Span({ classes("fw-bold") }) { Text("Count: $count") } + } + } + } +} diff --git a/site/src/jsMain/resources/index.html b/site/src/jsMain/resources/index.html new file mode 100644 index 0000000..723081f --- /dev/null +++ b/site/src/jsMain/resources/index.html @@ -0,0 +1,45 @@ + + + + +
+ + +