Skip to content
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

Please provide full example for a kotlin project #413

Open
ogesaku opened this issue Dec 9, 2024 · 3 comments
Open

Please provide full example for a kotlin project #413

ogesaku opened this issue Dec 9, 2024 · 3 comments

Comments

@ogesaku
Copy link

ogesaku commented Dec 9, 2024

Hey, thanks for the library!

I would like to use jte in a kotlin project, but keep hitting walls. It would be really handy to have a full example of the most basic usage:

  • any web server using .kte templates
  • jte-kotlin as compileOnly as described in Add kotlin and kte documentation #351
  • template hot-reloading for development and precompilation for production
  • configured using build.gradle.kts - as this is the standard for modern kotlin projects

My findings so far:

  • jte-kotlin as compileOnly doesn't work for development. Fails with gg.jte.TemplateException: Failed to create kotlin generator. To handle .kte files, you need to add gg.jte:jte-kotlin to your project.. Unfortunately I think it must be specified as implementation but then it comes with a whole lot of kotlin compilation dependencies.
  • Intellij jte plugin stops working randomly (stops displaying hints), doesn't recognise nested fields and fails for @import with Package directive and imports are forbidden in code fragments

Env:

  • Intellij: IntelliJ IDEA 2024.3 (Community Edition) Build #IC-243.21565.193, built on November 13, 2024, Kotlin plugin: K2 mode
  • kotlin: 2.0.21, 2.0.20
@casid
Copy link
Owner

casid commented Jan 3, 2025

Hi @ogesaku,

I don't use much Kotlin so can't help with most points here.

But, there is currently a problem with the IntelliJ plugin in K2 mode, with no practical solution yet: casid/jte-intellij#49

You could try if disabling K2 mode in IntelliJ helps, but this isn't a long term solution I'm afraid.

@domgom
Copy link

domgom commented Jan 13, 2025

I have basically the same feedback, couldn't get to work the gradle plugin with jooby.
create testapp -g --docker -k --openapi --server netty

and simply trying adding to the build.gradle.kts:

plugins {
    id("java")
    id("gg.jte.gradle") version "3.1.15" // this fails
}

dependencies {
    implementation("gg.jte:jte:3.1.15")
}

jte {
    generate()
}

Crashes with error:
java.lang.NoClassDefFoundError: Could not initialize class org.jetbrains.kotlin.gradle.report.ConfigureReporingKt (...)

My setup:
------------------------------------------------------------
Gradle 8.6
------------------------------------------------------------

Build time:   2024-02-02 16:47:16 UTC
Revision:     d55c486870a0dc6f6278f53d21381396d0741c6e

Kotlin:       1.9.20
Groovy:       3.0.17
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          21.0.5 (Homebrew 21.0.5)
OS:           Mac OS X 15.1.1 aarch64

Upon upgrading Gradlew versions to 8.7 and up to current 8.12 I get a different error:

* What went wrong:
class org.jetbrains.kotlin.build.report.metrics.GradleBuildTime can not implement org.jetbrains.kotlin.build.report.metrics.BuildTime, because it is not an interface (org.jetbrains.kotlin.build.report.metrics.BuildTime is in unnamed module of loader org.g

Is there a compatibility matrix on what gradle, gradle plugin, kotlin and jte versions are working? I find strange to have a jte-kotlin maven example and not a kotlin-gradle one when the majority of kotin projects use gradle.
I understand that K2 and the Intellij plugin are not working, but I would even settle for no IDE support, not .kte support, etc.. if I was able to get at least the gradle plugin working with .jte files.

Let me know if there is anything I can help.

@casid
Copy link
Owner

casid commented Jan 18, 2025

It seems there are some problems with the jte gradle plugin and the latest version of Kotlin. #412

I think @marcospereira is working on a fix here #411, but I can't tell you when that one will be ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants