Migration from 8.x to 9.x
KVision 9.0.0 is a major upgrade with changes affecting both functionalities and application structure. The goal of this release is to simplify the maintenance of the framework and allow me to continue supporting it. This required sacrificing several modules that, to my knowledge, were not widely (or even at all) used. At the same time, the KVision architecture was modernized, allowing for fixing issues and adding support for new features.
This is the list of incompatibilities you may encounter when migrating your application to KVision 9.0.0.
General changes
The
kvision-electron,kvision-cordovaandkvision-onsenuimodules were removed. If you use any of these modules, migration to KVision 9.x is not possible. Please let me know if this is your case.All code has been migrated to ES modules and
es2015target. As a result therequirefunction, used for importing resources and integrating NPM libraries, is no longer available. Use@JsModuleannotation instead. For instance, if you use this code to import CSS and JSON files:
class App : Application() {
init {
require("css/kvapp.css")
}
override fun start() {
I18n.manager =
DefaultI18nManager(
mapOf(
"en" to require("i18n/messages-en.json"),
"pl" to require("i18n/messages-pl.json"),
)
)
// ...
}
}you should now use this:
You need to move the resources processed by webpack (e.g. css files, images, po files or hbs templates) to the src/jsMain/resources/modules directory and use /kotlin/modules prefix, when importing them.
Replace
src/jsMain/resources/i18n/messages.potwithsrc/jsMain/resources/modules/i18n/messages.potin the.gettext.jsonfile, if you have it in your project.Change
module.hottojs("import.meta.webpackHot").unsafeCast<Hot?>()when using HMR.Move the content of the
src/jsMain/webdirectory tosrc/jsMain/resources. Thewebdirectory is no longer used.Add
useEsModules()andcompilerOptions { target.set("es2015") }to yourbuild.gradle.ktsfile. Check Creating new application chapter for reference.Add
kotlin.js.ir.output.granularity=per-fileproperty to yourgradle.propertiesfile.When using
kvision-pacemodule with the default theme, you need to provide a parameter toPace.init()call. Use the code like this:
Remove these two lines from
webpack.config.d/webpack.jsfile:
Fullstack changes
All kvision-server-* modules were removed and KVision by itself no longer provides fullstack interfaces. You have to migrate your application to use Kilua RPC library. This library was created as a standalone project that modernizes concepts originally implemented in KVision.
KVision still provides kvision-common-remote module, which supports date and time types declared in io.kvision.types package, so you don't have to change your application logic.
To migrate your application:
Add versions of KSP and Kilua RPC to your gradle.properties file:
Add two Gradle plugins to your project:
Remove
kvision-server-*dependency from your common source set and add new dependencies on Kilua RPC (useimplementation()instead ofapi()):
Kilua RPC doesn't support Guice, so if you are using it in your app, you should migrate to Koin or use manual bindings without any dependency injection, like this:
Replace annotations in your common code:
io.kvision.annotations.KVServicetodev.kilua.rpc.annotations.RpcServiceio.kvision.annotations.KVBindingtodev.kilua.rpc.annotations.RpcBindingio.kvision.annotations.KVBindingMethodtodev.kilua.rpc.annotations.RpcBindingMethodio.kvision.annotations.KVBindingRoutetodev.kilua.rpc.annotations.RpcBindingRouteio.kvision.annotations.KVServiceExceptiontodev.kilua.rpc.annotations.RpcServiceException
Replace types:
io.kvision.types.Decimaltodev.kilua.rpc.types.Decimalio.kvision.remote.RemoteOptiontodev.kilua.rpc.RemoteOptionio.kvision.remote.SimpleRemoteOptiontodev.kilua.rpc.SimpleRemoteOptionio.kvision.remote.RemoteDatatodev.kilua.rpc.RemoteDataio.kvision.remote.RemoteFiltertodev.kilua.rpc.RemoteFilterio.kvision.remote.RemoteSortertodev.kilua.rpc.RemoteSorterio.kvision.remote.RemoteSerializationtodev.kilua.rpc.RpcSerializationio.kvision.remote.ServiceExceptiontodev.kilua.rpc.ServiceExceptionio.kvision.remote.SecurityExceptiontodev.kilua.rpc.SecurityExceptionio.kvision.remote.ContentTypeExceptiontodev.kilua.rpc.ContentTypeExceptionio.kvision.remote.KVServiceManagertodev.kilua.rpc.RpcServiceManager
Your service class in JVM sources set should no longer be
actual. Removeactualkeyword and@Suppress("ACTUAL_WITHOUT_EXPECT")annotation if you use it.Replace functions:
io.kvision.remote.getServiceManagertodev.kilua.rpc.getServiceManagerio.kvision.remote.getAllServiceManagerstodev.kilua.rpc.getAllServiceManagersio.kvision.remote.serviceMatcherstodev.kilua.rpc.serviceMatchersio.kvision.remote.getServicetodev.kilua.rpc.getService
Replace
kv_remote_url_prefixconfiguration option withrpc_url_prefix.Add
registerRemoteTypes()call to yourmain()functions in bothjsandjvmsources set.The production version of the application is now assembled with
jarWithJsGradle task.
Spring Boot
You need to modify the structure of your Spring Boot project, because Kotlin 2.1.20 no longer supports using Kotlin Multiplatform and Spring Boot Gradle plugin in the same module. You need to add additional
applicationsubmodule. Please checkaddressbook-fullstack-spring-bootexample application for reference.Using
io.spring.dependency-managementGradle plugin can cause problems with dependencies (see KT-75643). Use Spring BOM instead.
Last updated