Using kotlin data classes in jte templates have issues compiling java sourceset.
See original GitHub issueI have the following project setup.
└── src
├── main
│ ├── java
│ │ └── dev
│ │ └── ...
│ ├── kotlin
│ │ └── dev
│ │ ├── jte
│ │ │ └── RenderJte.kt
│ └── templates
│ └── jte
│ └── hello.jte
Jte template (hello.jte
) uses a kotlin data classes
@import dev.suresh.jte.Config
@import java.time.LocalDateTime
@param Config config
Hello ${config.getLanguage()} - ${config.getVersion()}
Rendered By Jte on ${LocalDateTime.now().toString()}
import gg.jte.*
import gg.jte.output.*
data class Config(val language: String, val version: String)
class RenderJte {
fun run() {
val tmplEngine = TemplateEngine.createPrecompiled(ContentType.Plain)
val output = StringOutput()
tmplEngine.render("hello.jte", Config("Kotlin", App.KOTLIN_VERSION), output)
println(output)
}
}
Kotlin Gradle script setup is,
plugins {
java
application
kotlin("jvm") version "1.4.3"
id("gg.jte.gradle") version "1.7.0"
}
// Add the generated templates to source set.
sourceSets {
main {
java.srcDirs(
tasks.generateJte.get().targetDirectory
)
}
}
tasks {
withType<JavaCompile>().configureEach {
....
dependsOn(generateJte)
}
// Jte templates
generateJte {
sourceDirectory = Path.of("src", "main", "templates", "jte")
contentType = ContentType.Plain
}
}
The issue here is, once we add generateJte
dependency on javaCompile
task, it’s missing java classes (src/main/java
) classes in the final jar
.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Java module depending on Kotlin module unable to compile
I have been running into some strange issues when depending on a gradle module that uses Kotlin. I have setup a small demo...
Read more >Confusing data class copy with private constructor
When the primary constructor of data classes is private, copy() probably should be private ... Just released a compiler plugin that helps with...
Read more >Generate a Java file and include it in the sourceSet for ...
Assuming that I might have something like src/main/java/foo/bar.java … ... file from a template, then include it as part of the source set...
Read more >Known issues with Android Studio and Android Gradle Plugin
lifecycle:lifecycle-runtime in your module. If you're seeing java.lang.NoClassDefFoundError: Could not initialize class androidx.customview.poolingcontainer.
Read more >Rendering jte templates in Javalin
Introductionjte is a modern, type-safe template engine, that glues HTML and Java with as little extra syntax as possible.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sureshg I just published version
1.7.0.1
of the gradle plugin containing this hotifx.https://plugins.gradle.org/plugin/gg.jte.gradle
Sweet! Thanks for testing it and sharing your code sample!
I’ve updated the gradle kts documentation 👍