karakum-team / karakum

Converter of TypeScript declaration files to Kotlin declarations
Apache License 2.0
42 stars 2 forks source link

How to use the Kotlin Gradle plugin? #5

Closed shubhamsinghshubham777 closed 1 year ago

shubhamsinghshubham777 commented 1 year ago

The README.md file of this repository shows that there's a Kotlin Gradle plugin available i.e.

plugins {
    id("io.github.sgrishchenko.karakum") version "1.0.0-alpha.14"
}

but there is no guide that shows how to use it in a project. Could you please at least add an example on how to use it?

joffrey-bion commented 1 year ago

From what I could gather by reading the code, you just have to add the plugin like you did, and then add a karakum.config.json at the root of your project (next to your build.gradle.kts file). For example, for the @blueprintjs/icons NPM package, I used this config:

{
    "input": "<nodeModules>/@blueprintjs/icons/lib/esm/index.d.ts",
    "output": "src/jsMain/generated",
    "libraryName": "blueprintjs-icons"
}

Note that you can literally use <nodeModules> as a placeholder that will automatically be replaced by the plugin to the actual node modules path.

Then, the Karakum Gradle plugin will provide 3 tasks for you (check the karakum group in Gradle tasks). One of which is generateKarakumExternals, which is the main one you should need.

shubhamsinghshubham777 commented 1 year ago

Thanks for the explanation @joffrey-bion 🌟 Closing this issue now ✅