I've used create-react-kotlin-app and now I'd like...
# javascript
f
I've used create-react-kotlin-app and now I'd like to include a gradle/maven library. How to go about this? I've managed to track down the .jar file but I'm not sure how to include the jar / call it within kotlin. Please help 😅
h
In your build.gradle for the project, add the following to the dependencies section:
Copy code
implementation("some.group:some-artifact:version")
Then you dion’t need the jar file
f
I don't build with gradle directly, the npm run handles this
Thanks for the quick reply though
j
I had the same issue and I believe CRKA doesn't support this. I believe you have to move to a Gradle build if you want to do this, but then you lose the ability to mix JS and Kotlin... I would love to be wrong about this, but when I searched for a solution 1-2 years ago, I didn't find anything.
f
Oh man that would suck. What do the projects built with crka to serialize json then? @Joffrey
npm libraries?
j
I would believe so. If you want to serialize only, then
JSON.stringify()
is available in Kotlin/JS out-of-the-box
If you also want to deserialize JSON into Kotlin data classes, then it's another story... (see my post right above yours)
I am no expert in Kotlin/JS though, so maybe wait for an answer from the JetBrains team
f
Okay, I've read it, thanks. Well I'll continue to look for a good solution
j
Most of the Kotlin/JS libraries should also be distributed as npm packages, though, if we want the JS world to adopt them. My main problem back then was that my "maven/gradle" dependency was in fact another module in my project.
A drastic solution for you if you really need a maven dependency of a Kotlin/JS library is to create a mini gradle project depending on the library and publishing it as an npm package
f
No, it's not that important, I just would have liked to use kotlinx:serialization in my project as it seems the only library to parse json effectively within kotlin
This means that an npm package wouldn't really work as I want to make use of typesafety and automatic deserialization into (data) classes
j
I have almost no experience with CRKA, but can't npm dependencies include Kotlin definition files? You should still be able to benefit from the type safety. I'm not sure anymore