-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gradle plugin #6
Comments
You can create a gradle task if it makes sense for you. Hopefully there is no inconvenience, it's just instantiating a class, calling a method and writing the results to a file, all of which vary a lot depending on your project. |
I'm really not familiar on how to do this but I'll give it a try and report back here. I suspect that this is a common usage scenario, especially when combined with Kotlin Multiplatform projects |
Hello. Here is the Gradle plugin: |
@alexvas doesn't work |
@forresthopkinsa may you provide a sample that doesn't work? |
I ended up just implementing it myself, it was much easier to do. TypeDefGenerator.kt: package com.forresthopkinsa.braze.model
import me.ntrrgc.tsGenerator.TypeScriptGenerator
fun main() {
val classes = setOf(
RestController.Constants::class,
JavaVersion::class,
)
val ignored = setOf(
Element::class,
SimpleElement::class,
Data::class
)
val definitions = TypeScriptGenerator(rootClasses = classes, ignoreSuperclasses = ignored).definitionsText
println(definitions)
} build.gradle.kts: repositories {
...
maven { url = uri("https://jitpack.io") }
}
dependencies {
...
compile("com.github.ntrrgc", "ts-generator", "1.1.1")
}
val generateDefinitions by tasks.creating(JavaExec::class) {
classpath = sourceSets["main"].runtimeClasspath
main = "com.forresthopkinsa.braze.model.TypeDefGeneratorKt"
standardOutput = File(buildDir, "kotlin-model.d.ts").outputStream()
}
val copyDefinitions by tasks.creating(Copy::class) {
from(File(buildDir, "kotlin-model.d.ts"))
destinationDir = File(projectDir, "src/frontend/src")
} |
I've create a Gradle plugin for ts-generator: Let me know what you think. If you like it, I'd appreciate a ⭐️ :) |
This is a very cool project. However, wouldn't it make more sense to run this as part of a Gradle plugin, during the build process, and not as a part of the application's code itself?
I see this as something similar to the
kotlin2js
plugin.The text was updated successfully, but these errors were encountered: