diff --git a/build.gradle.kts b/build.gradle.kts index 12118ea..1fbc6de 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -137,7 +137,7 @@ android { } // TODO Extract the code below to another file // ------------------------- Publication configuration --------------------- // - +val releaseVersion = !version.toString().endsWith("-SNAPSHOT") val sonatypeUsername = System.getenv("ORG_GRADLE_PROJECT_mavenCentralUsername") ?: "" val sonatypePassword = System.getenv("ORG_GRADLE_PROJECT_mavenCentralPassword") ?: "" val versionName = System.getenv("VERSION_NAME") ?: project.property("VERSION_NAME").toString() @@ -178,7 +178,7 @@ publishing { name="oss" val releasesRepoUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") val snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") - url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl + url = if (releaseVersion) releasesRepoUrl else snapshotsRepoUrl credentials { username = sonatypeUsername password = sonatypePassword @@ -221,6 +221,12 @@ publishing { } signing { + setRequired { + // signing is required if this is a release version and the artifacts are to be published + // do not use hasTask() as this require realization of the tasks that maybe are not necessary + releaseVersion && gradle.taskGraph.allTasks.any { it is PublishToMavenRepository } + } + @Suppress("UnstableApiUsage") sign(publishing.publications) } diff --git a/src/commonMain/kotlin/com/zup/nimbus/core/network/ViewRequest.kt b/src/commonMain/kotlin/com/zup/nimbus/core/network/ViewRequest.kt index 1111dcf..96598f1 100644 --- a/src/commonMain/kotlin/com/zup/nimbus/core/network/ViewRequest.kt +++ b/src/commonMain/kotlin/com/zup/nimbus/core/network/ViewRequest.kt @@ -21,4 +21,8 @@ data class ViewRequest( * UI tree to show if an error occurs and the view can't be fetched. */ val fallback: Map? = null, + /** + * The map of state ids and its values that will be used on the next page. + */ + val params: Map? = null, ) diff --git a/src/commonMain/kotlin/com/zup/nimbus/core/ui/action/navigation.kt b/src/commonMain/kotlin/com/zup/nimbus/core/ui/action/navigation.kt index 99549ba..6c00328 100644 --- a/src/commonMain/kotlin/com/zup/nimbus/core/ui/action/navigation.kt +++ b/src/commonMain/kotlin/com/zup/nimbus/core/ui/action/navigation.kt @@ -6,24 +6,26 @@ import com.zup.nimbus.core.network.ServerDrivenHttpMethod import com.zup.nimbus.core.network.ViewRequest import com.zup.nimbus.core.ActionTriggeredEvent import com.zup.nimbus.core.utils.UnexpectedDataTypeError +import com.zup.nimbus.core.utils.then import com.zup.nimbus.core.utils.valueOfEnum import com.zup.nimbus.core.utils.valueOfKey private inline fun getNavigator(event: ActionEvent) = event.scope.view.navigator -private fun requestFromEvent(event: ActionEvent): ViewRequest { +private fun requestFromEvent(event: ActionEvent, isPushOrPresent: Boolean): ViewRequest { val properties = event.action.properties return ViewRequest( url = valueOfKey(properties, "url"), method = valueOfEnum(properties, "method", ServerDrivenHttpMethod.Get), headers = valueOfKey(properties, "headers"), fallback = valueOfKey(properties, "fallback"), + params = (isPushOrPresent then valueOfKey(properties, "params")), ) } private fun pushOrPresent(event: ActionTriggeredEvent, isPush: Boolean) { try { - val request = requestFromEvent(event) + val request = requestFromEvent(event, true) if (isPush) getNavigator(event).push(request) else getNavigator(event).present(request) } catch (e: UnexpectedDataTypeError) { @@ -51,7 +53,7 @@ internal fun onPushOrPresentInitialized(event: ActionInitializedEvent) { try { val prefetch: Boolean = valueOfKey(event.action.properties, "prefetch") ?: false if (!prefetch) return - val request = requestFromEvent(event) + val request = requestFromEvent(event, true) event.scope.nimbus.viewClient.preFetch(request) } catch (e: Throwable) { event.scope.nimbus.logger.error("Error while pre-fetching view.\n${e.message}")