diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml index 931b96c3..16660f1d 100644 --- a/.idea/runConfigurations.xml +++ b/.idea/runConfigurations.xml @@ -5,8 +5,12 @@ diff --git a/.idea/runConfigurations/Plugin___run_ide.xml b/.idea/runConfigurations/Plugin___run_ide.xml new file mode 100644 index 00000000..66d166dc --- /dev/null +++ b/.idea/runConfigurations/Plugin___run_ide.xml @@ -0,0 +1,24 @@ + + + + + + + true + true + false + false + + + \ No newline at end of file diff --git a/.idea/runConfigurations/Plugin___sign__for_release_.xml b/.idea/runConfigurations/Plugin___sign__for_release_.xml new file mode 100644 index 00000000..2a488000 --- /dev/null +++ b/.idea/runConfigurations/Plugin___sign__for_release_.xml @@ -0,0 +1,24 @@ + + + + + + + true + true + false + false + + + \ No newline at end of file diff --git a/.idea/runConfigurations/Plugin___verify.xml b/.idea/runConfigurations/Plugin___verify.xml new file mode 100644 index 00000000..3d3c618b --- /dev/null +++ b/.idea/runConfigurations/Plugin___verify.xml @@ -0,0 +1,25 @@ + + + + + + + true + true + false + false + + + \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Util.kt b/buildSrc/src/main/kotlin/Util.kt index 63799467..08154cc2 100644 --- a/buildSrc/src/main/kotlin/Util.kt +++ b/buildSrc/src/main/kotlin/Util.kt @@ -71,3 +71,5 @@ fun Config.version(isRelease: Boolean) = buildString { append(versionName) if (!isRelease) append("-SNAPSHOT") } + +fun Project.namespaceByPath() = "${Config.namespace}.${path.replace(":", ".").removePrefix(".")}" diff --git a/debugger/server/build.gradle.kts b/debugger/server/build.gradle.kts index 038f889d..1f08a5ad 100644 --- a/debugger/server/build.gradle.kts +++ b/debugger/server/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi + plugins { id(libs.plugins.kotlinMultiplatform.id) alias(libs.plugins.compose) @@ -5,6 +7,32 @@ plugins { alias(libs.plugins.serialization) } +val parentNamespace = namespaceByPath() + +// must be earlier than other config or build tasks +val generateBuildConfig by tasks.registering(Sync::class) { + from( + resources.text.fromString( + """ + package $parentNamespace + + object BuildFlags { + const val VersionCode = ${Config.versionCode} + const val VersionName = "${Config.versionName}" + const val SupportEmail = "${Config.supportEmail}" + const val ProjectUrl = "${Config.url}" + + } + """.trimIndent() + ) + ) { + rename { "BuildFlags.kt" } + into(parentNamespace.replace(".", "/")) + } + // the target directory + into(layout.buildDirectory.dir("generated/kotlin/src/commonMain")) +} + compose.resources { publicResClass = true } @@ -14,15 +42,20 @@ tasks { sourceCompatibility = Config.jvmTarget.target targetCompatibility = Config.jvmTarget.target } + } kotlin { jvm { + @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { jvmTarget = Config.jvmTarget } } sourceSets { + commonMain { + kotlin.srcDir(generateBuildConfig.map { it.destinationDir }) + } commonMain.dependencies { implementation(projects.core) implementation(projects.compose) diff --git a/debugger/server/src/commonMain/kotlin/pro/respawn/flowmvi/debugger/server/arch/configuration/BuildFlags.kt b/debugger/server/src/commonMain/kotlin/pro/respawn/flowmvi/debugger/server/arch/configuration/BuildFlags.kt index 1a64ad97..9da75edc 100644 --- a/debugger/server/src/commonMain/kotlin/pro/respawn/flowmvi/debugger/server/arch/configuration/BuildFlags.kt +++ b/debugger/server/src/commonMain/kotlin/pro/respawn/flowmvi/debugger/server/arch/configuration/BuildFlags.kt @@ -1,5 +1,5 @@ package pro.respawn.flowmvi.debugger.server.arch.configuration -data object BuildFlags { - val debuggable = System.getenv("DEBUG")?.toBooleanStrictOrNull() ?: false -} +import pro.respawn.flowmvi.debugger.server.BuildFlags + +val BuildFlags.debuggable by lazy { System.getenv("DEBUG")?.toBooleanStrictOrNull() ?: false } diff --git a/debugger/server/src/commonMain/kotlin/pro/respawn/flowmvi/debugger/server/arch/configuration/DefaultStoreConfiguration.kt b/debugger/server/src/commonMain/kotlin/pro/respawn/flowmvi/debugger/server/arch/configuration/DefaultStoreConfiguration.kt index ba16fcde..890982c2 100644 --- a/debugger/server/src/commonMain/kotlin/pro/respawn/flowmvi/debugger/server/arch/configuration/DefaultStoreConfiguration.kt +++ b/debugger/server/src/commonMain/kotlin/pro/respawn/flowmvi/debugger/server/arch/configuration/DefaultStoreConfiguration.kt @@ -8,6 +8,7 @@ import pro.respawn.flowmvi.api.ActionShareBehavior import pro.respawn.flowmvi.api.MVIAction import pro.respawn.flowmvi.api.MVIIntent import pro.respawn.flowmvi.api.MVIState +import pro.respawn.flowmvi.debugger.server.BuildFlags import pro.respawn.flowmvi.dsl.StoreBuilder import pro.respawn.flowmvi.plugins.enableLogging import pro.respawn.flowmvi.savedstate.api.NullRecover diff --git a/debugger/server/src/commonMain/kotlin/pro/respawn/flowmvi/debugger/server/ui/widgets/RErrorView.kt b/debugger/server/src/commonMain/kotlin/pro/respawn/flowmvi/debugger/server/ui/widgets/RErrorView.kt index 4101dff7..253596e4 100644 --- a/debugger/server/src/commonMain/kotlin/pro/respawn/flowmvi/debugger/server/ui/widgets/RErrorView.kt +++ b/debugger/server/src/commonMain/kotlin/pro/respawn/flowmvi/debugger/server/ui/widgets/RErrorView.kt @@ -7,7 +7,13 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.text.LinkAnnotation +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.style.TextDecoration +import androidx.compose.ui.text.withLink import androidx.compose.ui.unit.sp +import pro.respawn.flowmvi.debugger.server.BuildFlags +import pro.respawn.kmmutils.compose.annotate @Composable fun RErrorView( @@ -20,8 +26,15 @@ fun RErrorView( ) { Text("An error has occurred", fontSize = 32.sp) SelectionContainer { - Text("Message: ${e.message}") - Text("stack trace: ${e.stackTraceToString()}") - // TODO: Report to github link + Column { + Text("Message: ${e.message}") + Text("stack trace: ${e.stackTraceToString()}", fontFamily = FontFamily.Monospace) + Text( + textDecoration = TextDecoration.Underline, + text = "Please report this to Github".annotate { + withLink(LinkAnnotation.Url(BuildFlags.ProjectUrl)) { append(it) } + } + ) + } } }