rjaros / kvision

Object oriented web framework for Kotlin/JS
https://kvision.io
MIT License
1.23k stars 65 forks source link

KV Project inside multiproject gradle doesn't generate KSP sources #478

Closed tfonrouge closed 1 year ago

tfonrouge commented 1 year ago

Hi all,

I've a full-stack KVision App which perfectly serves his purpose, but then I wrote an Android app which consumes data from the backend from the KVision App.

My solution was (due to my lack of gradle knowledge) to separate part of the data model described mainly in the COMMON in a separated project in order to build a library that can be consumed by my Android and KVision projects.

Ok, up to here all seems to be alright, but suddenly the (frequently) desire to simplify things through complicated paths took me to finally want to have a single project from which I can deliver the KVision App and the (MPP) data model Library to be consumed by the Android and KVision apps.

The new gradle project holds the KVision project, and the (MPP) data model Library, great !, it can build and publish (to maven local) the MPP Library that can be used with no trouble with the Android project.

But... in the KVision project seems to be that the KSP processor is not running at all because the @KVService implementations of frontend/common are not builded: the KVision project frontend complains with errors on @KVServices interfaces not implemented and the backend shows at start: Exception in thread "main" kotlin.NotImplementedError: KVision didn't generate code. You need to apply KVision Gradle Plugin.

I've builded a simple gradle multiproject that shows the problem, has the following structure:

├── buildSrc
│   ├── src
│   │   └── main
│   │       └── kotlin
│   │           ├── kvmpp1.kotlin-common-conventions.gradle.kts
│   │           ├── kvmpp1.kotlin-kvision-full-stack-conventions.gradle.kts
│   │           └── kvmpp1.kotlin-mpp-library-conventions.gradle.kts
│   ├── build.gradle.kts
│   └── settings.gradle.kts
├── gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── kvProject1
│   ├── src
│   │   ├── backendMain
│   │   │   ├── kotlin
│   │   │   │   └── com
│   │   │   │       └── example
│   │   │   │           └── project
│   │   │   │               ├── Main.kt
│   │   │   │               └── Service.kt
│   │   │   └── resources
│   │   │       ├── application.conf
│   │   │       └── logback.xml
│   │   ├── commonMain
│   │   │   └── kotlin
│   │   │       └── com
│   │   │           └── example
│   │   │               └── project
│   │   │                   └── Service.kt
│   │   ├── frontendMain
│   │   │   ├── kotlin
│   │   │   │   └── com
│   │   │   │       └── example
│   │   │   │           └── project
│   │   │   │               ├── App.kt
│   │   │   │               └── Model.kt
│   │   │   └── web
│   │   │       └── index.html
│   │   └── frontendTest
│   │       └── kotlin
│   │           └── test
│   │               └── com
│   │                   └── example
│   │                       └── project
│   │                           └── AppSpec.kt
│   ├── webpack.config.d
│   │   ├── bootstrap.js
│   │   ├── css.js
│   │   ├── file.js
│   │   ├── handlebars.js
│   │   └── webpack.js
│   └── build.gradle.kts
├── mppLib
│   ├── src
│   │   ├── androidLibMain
│   │   │   ├── kotlin
│   │   │   │   └── com
│   │   │   │       └── example
│   │   │   │           └── mppLib
│   │   │   └── resources
│   │   ├── backendMain
│   │   │   ├── kotlin
│   │   │   │   └── example
│   │   │   │       └── com
│   │   │   │           └── mppLib
│   │   │   └── resources
│   │   ├── commonMain
│   │   │   ├── kotlin
│   │   │   │   └── example
│   │   │   │       └── com
│   │   │   │           └── mppLib
│   │   │   │               └── Person.kt
│   │   │   └── resources
│   │   ├── frontendMain
│   │   │   ├── kotlin
│   │   │   │   └── mppLib
│   │   │   └── resources
│   │   └── test
│   │       ├── kotlin
│   │       │   └── kvmpp1
│   │       └── resources
│   └── build.gradle.kts
├── gradle.properties
├── gradlew
├── gradlew.bat
├── local.properties
└── settings.gradle.kts

The project loads correctly the build.gradle.kts scripts.

The library :mppLib contains a data class Person which is visible on the kvProject1 on backend/frontend.

The library (:mppLib) can be builded and published correctly with ./gradlew :mppLib:publishToMavenLocal

By doing a ./gradlew :kvProject1:frontendRun doesn't show any errors.

By doing a ./gradlew ::kvProject1:backendRun shows:

Exception in thread "main" kotlin.NotImplementedError: KVision didn't generate code. You need to apply KVision Gradle Plugin.

The KVision app is a simple full-stack app with current KVision v6.3.2, and uses gradle v8.0.2

The project is available in github on:

https://github.com/tfonrouge/kvmpp1

Any help will be greatly appreciated :-)

Thanks in advance for any insight !

Teo

rjaros commented 1 year ago

Hi The project seems to run for me after uncommenting the KVision gradle plugin here: https://github.com/tfonrouge/kvmpp1/blob/master/kvProject1/build.gradle.kts#L10-L11

tfonrouge commented 1 year ago

Thank you !

Too much cofee for me this week ...

Thanks again :-)