casid / jte

Secure and speedy templates for Java and Kotlin.
https://jte.gg
Apache License 2.0
737 stars 54 forks source link

KTE runtime dependencies #363

Closed Jerbell closed 2 months ago

Jerbell commented 2 months ago

Hi - I'm trying to reduce dependency libraries in my app.

I've noticed that the docs say that jte-kotlin should be compile only (https://jte.gg/kotlin/): compileOnly "gg.jte:jte-kotlin:3.1.11". However, if I set normal JTE to be included at runtime, and jte-kotlin to be compileOnly then it doesn't work: You're missing the 'jte-kotlin' dependency in your project. Add the dependency:\n\npom.xml:\n<dependency>\n <groupId>gg.jte</groupId>\n <artifactId>jte-kotlin</artifactId>\n <version>2.2.1</version>\n</dependency>\n\nbuild.gradle or build.gradle.kts:\nimplementation("gg.jte:jte-kotlin:2.2.1")

Is it necessary to include jte-kotlin and by dependency kotlin-compiler-embeddable-1.9.10.jar for the runtime?

Thanks!

casid commented 2 months ago

Hi @Jerbell,

that's odd, both and jte-runtime have no dependency to jte-kotlin.

Since gg.jte:jte-kotlin:2.2.1 is quite old, I'm wondering if this is being pulled in transitive, e.g. by another framework?

Jerbell commented 2 months ago

I didn't notice the version but yes that's old. There are no other front end frameworks & can't imagine one including jte-kotlin. I'll have more of a look.

Jerbell commented 2 months ago

I should clarify this is an app start up/runtime error, not a compile error.

Jerbell commented 2 months ago

Also the KTE files are included in a sub-module. So we're talking about a jar inside the jar. (not sure if this is relevant, but maybe it is) If this isn't making sense I could do up a small sample project to demonstrate.

Jerbell commented 2 months ago

Also (sorry about the spam) generate() and precompile() both have the same issues.

marcospereira commented 2 months ago

Can you post the full stack trace for that error? Also, what is the output of running ./gradlew dependencies?

Jerbell commented 2 months ago

I'm so sorry - it looks like this is coming from Javalin!

java.lang.IllegalStateException:
#########################################################################
You're missing the 'jte-kotlin' dependency in your project. Add the dependency:

pom.xml:
<dependency>
    <groupId>gg.jte</groupId>
    <artifactId>jte-kotlin</artifactId>
    <version>2.2.1</version>
</dependency>

build.gradle or build.gradle.kts:
implementation("gg.jte:jte-kotlin:2.2.1")
#########################################################################
        at io.javalin.rendering.util.Util.throwIfNotAvailable(RenderingDependency.kt:36)
        at com.company.xxx.configLibConfig.<init>(LibConfig.kt:43)
        at com.company.xxx.config.LibConfig.<init>(LibConfig.kt:20)
        at com.company.xxx.config.AppConfig.<init>(AppConfig.kt:18)
        at App.runApp(Main.kt:30)
        at com.company.shared.commands.AbstractMain.run(AbstractMain.kt:53)
        at com.github.ajalt.clikt.parsers.Parser.finalizeAndRun(Parser.kt:348)
        at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:218)
        at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:42)
        at com.github.ajalt.clikt.core.CliktCommand.parse(CliktCommand.kt:457)
        at com.github.ajalt.clikt.core.CliktCommand.parse$default(CliktCommand.kt:454)
        at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:474)
        at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:481)
        at MainKt.main(Main.kt:65)

I'll hunt this down more & close when I've resolved where the issue is.

Jerbell commented 2 months ago

Ok - so it turns out I had some code in there which checked at runtime we had the required dependencies. I apologise for wasting your time. Thanks!